# Welcome the user ("student" on the NETLAB+ Linux computer) echo "Hello, your username is `whoami`. Let's count 10 lines." # Set the count variable to 1 at first count=1 # Start a loop that runs while count is less than 11 while [ $count -lt 11 ] do # Print the line number depending on what count currently equals echo "This is line number $count!" # Tell the user that we're almost done after line number 9 if [ $count -eq 9 ] then echo "Almost done..." fi # Add 1 to count and go back to the start of the loop count=`expr $count + 1` done
Write, Run & Share Bash code online using OneCompiler's Online Bash Shell for free. It's one of the robust, feature-rich Bash shell available over online and getting started with the OneCompiler's Bash Shell is simple and pretty fast. The editor shows sample boilerplate code when you choose language as Bash
. OneCompiler also has reference scripts, where you can look for the sample scripts and start coding.
Bash (Bourne Again Shell) is a shell program written by Brian Fox and is an upgraded version of Bourne Shell program 'sh'.
name="Foo"
echo $name
echo "$name"
echo "${name}"
if [ conditional-expression ]
then
statements
fi
if [ conditional-expression ]
then
statements
else
statements
fi
if [ conditional-expression ]
then
statements
elif [ conditional-expression ]
then
statements
else
statements
fi