Create a new directory bash_scripts where you will run the
shell scripting exercises.
mkdir bash_scripts
cd bash_scripts
Note, it is recommended to create a new script file for every exercise; make them executable; give them names with
extension .sh -- it is just a convention rather than a must.
The first line of a bash script starts with
#!/bin/bash
All non-executable comments in a script are prepended with #
# For example, we list all the files in the current directory
ls -la
ls -l /etc # Comment. Here, we list files in /etc directory
Script scr1.sh is like a calculator:
#!/bin/bash
echo "I will work out X*Y"
echo "Enter X"
read X
echo "Enter Y"
read Y
echo "X*Y = $X*$Y = $[X*Y]"