Scripting Classroomnotes 03/Feb/2023

Shell Scripting Contd

  • Scripting is a list of commands that are executed in a particular order.
  • Generally the script executes the commands in the order they are written, but we can also specify

    • instructions to repeat the same command multiple times (loops)
    • to skip some commands based on some conditions (conditionals)
  • Sample script
echo 1
echo 2
echo 3
echo 4
echo 5
  • Execute this script
  • Consider the following activities
    • Create a directory under /opt/backup folder that has today’s date in the name eg /opt/backup/qtdevops-03022023
    • Copy all the files from /home/qtdevops/ into this directory
  • Solution:
    • Find a command to get the date and then data in some format.
    • Refer Here for the script added


  • Variables will store the value and we can use the values further in the script
  • Types of Variables:
    • Environmental Variables:
      • The shell maintains environmetal variables which are common to applications/scripts across the current session
      • To use the environmental variable $<ENV-VAR-NAME>
      • To set environmental variables you can use export command
    • User Variables:
      • These are the variables set in a shell script
      • Refer Here for the usage of user variables


  • Findout all the environmental and user variables in the Refer Here

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

About continuous learner

devops & cloud enthusiastic learner