k

Introduction Bash Scripting for Linux System Administrator

Variables

   site="davide"
   echo $name
   echo ${name}
   #!/bin/bash

   # Bash exp. script

   site="fixerupper"

   echo "What is your name?" 
   read name

   echo "Hi there $name"
   echo "Welcome to $site Website!"

If - then

   if [[ some_test ]]
   then   
      <commands>
   fi
   #!/bin/bash

   # Bash exp. script

   read -p "What is your name? " name
   if [[ -z $ {name} ]]
   then
     echo "Please enter your name!"
   else
       echo "Hi there ${ name}"
   fi

Loops for - while -until

for var in ${list}
do    
  your_commands
done
while [ your_condition ]
do    
  your_conditions
done
until [ your_condition ]
do    
  your_commands
done

continue - stop the current iteration of the loop and start the next iteration - end the loop straight away