Welcome to XCODX Online Compiler
Quick Start:
Ctrl+Enter Run code
Ctrl+S Save / Download
Ctrl+L Clear output
Select a language and start coding.
Welcome to XCODX Online Compiler
Quick Start:
Ctrl+Enter Run code
Ctrl+S Save / Download
Ctrl+L Clear output
Select a language and start coding.
When Debian or Ubuntu runs /bin/sh, the shell doing the work is Dash — the Debian Almquist Shell. It exists for two reasons: speed and strict POSIX compliance. Dash starts noticeably faster than Bash, which is why distributions use it for boot scripts and system scripting, and it deliberately omits Bash extensions like arrays and [[ ]], which makes it the honest test of whether your script is truly portable. If code runs in Dash, it will run on almost any Unix shell, from Alpine containers to BusyBox routers. Use the interactive terminal on this page to run POSIX shell scripts live — read prompts wait for your actual keystrokes, and there is nothing to install.
#!/bin/sh
printf "Enter your name: "
read name
echo "Hello, $name!"
printf "Enter a whole number: "
read n
i=1
sum=0
while [ "$i" -le "$n" ]; do
sum=$((sum + i))
i=$((i + 1))
done
echo "Sum of 1..$n is $sum"
case $sum in
*[02468]) echo "That total is even." ;;
*) echo "That total is odd." ;;
esac
Dash matters most when portability does: writing Docker entrypoint scripts for Alpine images, maintaining Debian package maintainer scripts, or authoring anything with a #!/bin/sh shebang that must survive on minimal systems. It is the right place to check whether a script leans on Bashisms — paste it here and the errors tell you immediately. Students in operating systems or Unix tools courses also benefit, because POSIX sh is the dialect textbooks and exams assume. Practicing read loops, case statements, and $((...)) arithmetic here builds shell skills that transfer everywhere.
Yes. read pauses the script and waits for a line from the terminal, and since this is a live interactive session your typed input flows straight to stdin. printf prompts render before the pause, so interactive scripts feel exactly like they do over SSH on a real server.
Dash implements the POSIX shell specification and little more. Bash features like arrays, [[ ]] conditionals, (( )) arithmetic commands, process substitution, and ${var//replace} expansions will fail in Dash. In exchange, Dash is smaller and faster, which is why Debian and Ubuntu point /bin/sh at it. Scripts that pass in Dash are highly portable.
Almost always a Bashism: your local sh may secretly be Bash. Common culprits are echo -e, source instead of ., ==, arrays, and $RANDOM. Replace them with POSIX equivalents — printf, . file, =, positional parameters or set --, and awk or /dev/urandom for randomness.
main.shshellread#!/bin/dash
# Dash - Debian Almquist Shell
echo "Hello from Dash!"
echo "Welcome to XCODX Online Compiler!"
# Variables and arithmetic
COUNT=5
echo "Counting to $COUNT:"
I=1
while [ "$I" -le "$COUNT" ]; do
echo " Number: $I"
I=$((I + 1))
done
echo "Done!"