[text] shell

Viewer

  1. #!/bin/bash
  2.  
  3. # Testing the if statement with pwd
  4. if [ "$(pwd)" ]
  5. then
  6.     echo "Present working directory is $(pwd)"
  7. fi
  8.  
  9. # Variables for comparison
  10. var1=20
  11. var2=10
  12.  
  13. # Comparing variables correctly
  14. if [ "$var1" -gt "$var2" ]; then
  15.     echo "$var1 is greater than $var2"
  16. else
  17.     echo "$var2 is greater than or equal to $var1"
  18. fi
  19.  
  20.  
  21. if [ "$var1" -lt "$var2" ]; then 
  22. echo "$var1 is lesser than $var2"
  23. else
  24. echo "$var2 is lesser than $var1"
  25. fi

Editor

You can edit this paste and save as new:


File Description
  • shell
  • Paste Code
  • 02 Jul-2024
  • 463 Bytes
You can Share it: