Sunday, May 22, 2022

Bash Scripting 8

Notations to check conditions 



  • The comparison of string or numeric is the main decision taken to check for certain condition.
  • The comparison like equal to, not equal, less than, greater than, less than or equal, greater than or equal, etc
  • These can also be represented in bash as 
    • equal to             :  -eq
    • not equal           :  -ne
    • greater than       :  -gt
    • less than            :  - lt
    • greater or equal :  -ge
    • less or equal      :  -le 
  • These will help greatly when using loops.
  • The way of using these format in conditional statement are similar to https://cybercheck123.blogspot.com/2022/05/bash-scripting-6.html
  • The only change is to replace these notation instead of symbols.
  • Examples :





  • Here if we use -eq the output will change because this is string comparison.The Notations will help to compare arithmetics.




  • Lets see with numeric examples:





  • Example to check greater of three number:








No comments:

Post a Comment

Google Cybersecurity Professional Certificate

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