Bash
v5.2.0
Bash
v5.2.0
Bash (the Bourne Again SHell) is a Unix shell and command language written by Brian Fox for the GNU Project as a free replacement for the Bourne shell, first released in 1989. It is both an interactive command interpreter and a scripting language, supporting variables, control structures, functions, pipelines, and command substitution.
Bash is the default login shell on most Linux distributions and is widely used for system administration, automation, build scripts, and gluing together command-line tools. Its ability to chain commands with pipes and redirections makes it an essential tool for DevOps, deployment scripts, and everyday workflow automation on Unix-like systems.
echo "Hello, World!"read -p "Enter your name: " name
echo "Hello, $name!"fruits=("apple" "banana" "cherry")
for i in "${!fruits[@]}"; do
echo "$((i + 1)): ${fruits[$i]}"
donefactorial() {
if [ "$1" -le 1 ]; then
echo 1
else
echo $(( $1 * $(factorial $(( $1 - 1 ))) ))
fi
}
factorial 5declare -A ages
ages[alice]=30
ages[bob]=25
for name in "${!ages[@]}"; do
echo "$name is ${ages[$name]}"
donefile="data.txt"
if [ -f "$file" ]; then
echo "$file exists"
else
echo "$file not found"
fi
name="bash"
if [[ "$name" == b* ]]; then
echo "starts with b"
fin=5
result=$((n * n))
echo "square: $result"
case "$n" in
1) echo "one" ;;
5) echo "five" ;;
*) echo "other" ;;
esacwhile IFS= read -r line; do
echo "Line: $line"
donepath="/usr/local/bin/script.sh"
echo "${path##*/}" # basename: script.sh
echo "${path%/*}" # dirname: /usr/local/bin
echo "${path/.sh/.bak}" # replace: ...script.bak
upper="HELLO"
echo "${upper,,}" # lowercase: hellocount=$(printf "a\nb\nc\n" | wc -l)
echo "lines: $count"
for word in $(echo "one two three"); do
echo "word: $word"
doneYes. CompileBytes runs your Bash scripts in the browser, so you can test shell scripting without a local Unix environment.
This compiler runs Bash 5.2.0, so syntax and built-ins available up to that release are supported.
Use the read command to capture input. Enter your text in the input/stdin panel before running the script.
Yes, running Bash on CompileBytes is completely free and requires no signup.
Common core utilities are available, but the sandbox may restrict network access and certain system commands for security.