Sunday, May 15, 2022

Bash Scripting 2

 Bash Scripting



NOTE : Bash scripts can be run using "bash <file_name.sh>"

  • Command : sleep <time in seconds>
    • This command is used to leave a small interval of time in seconds between the execution of the code.
    • The command after sleep execute once the given time gets over.

      Here the update command execute after 3 seconds. 1 2 3 will execute at the time interval of 1 second.



  • Using some Build in variable in bash:
    • RANDOM
      • This command is used to generate a random number.
      • The range of the number lies from 0 to 32767.
      • "$RANDOM" This command is used to produce the random variable.
    • SHELL
      • This command is used to display the current shell.
      • Command : "$SHELL"
    • PWD
      • This command is used to display the current working directory.
      • Command : "$PWD"
    • HOSTNAME
      • This command is used to diplay the host name.
      • Which host is currently active.
      • Command : "$HOSTNAME"




NOTE:
In the above example ,if $RANDOM is not displaying when using "./<file_name>" try 
bash <file_name> to run the script.










No comments:

Post a Comment

Google Cybersecurity Professional Certificate

    Google Cybersecurity Professional Certification 🔒 Google Cybersecurity Professional Certification: A Journey Unveiled! 🔒 Hey Folks! 🌟...