UnixTips.net

* use my tips at your own risk !!

* use my tips at your own risk !!

Categories

  • Other (3)
  • Scripting (10)
  • Unix (70)
  • Wordpress (2)

Powered by Genesis

operators

‘-eq’ and ‘=’. They are slightly different: ‘-eq’ is a integer comparison but ‘=’ is a string comparison.

Examples:

[[ 0 -eq 0000 ]]; echo $? # shows 0 (true)

[[ 0 = 0000 ]]; echo $? # shows 1 (false)

don’t forget to surround each $var1 with double quotes to prevent null chars.

if [ $var1 -eq $var2 -a $var3 = $var4 ]

– eq for numeric compare
= for string compare
-a is “and” operator