The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM



View Single Post in UNIX Forums - Click on the Thread or Permalink to View Entire Thread -->
  #4 (permalink)  
Old 05-19-2006
Corona688 Corona688 is offline
Registered User
 

Join Date: Aug 2005
Location: Saskatchewan
Posts: 923
UNIX is an operating system, not a commandline. You seem to be talking about the standard UNIX shell, sh or one of it's clones like bash, but could have as easily been using something like korn... or even been programming in C.... = and == are pretty common.

I've never seen code like your first example, probably because it doesn't work. ( ) brackets aren't statement grouping, they define arrays!
Code:
arr=(a = c)
echo ${arr[0]}
echo ${arr[1]}
echo ${arr[2]}
will print a, then =, then c. The = isn't even treated as an operator inside the ().

Inside the [[ ]] brackets, == is a pattern matching operator for strings, and = is a straight equality comparison. Outside of there, = is an assignment operator like variable="something" and I don't think == does anything.

Also, your if statements aren't quite right. Try this:

Code:
if [[ $this = "that" ]]
then
      echo "Something"
else
      echo "Something else"
fi

Last edited by Corona688; 05-19-2006 at 11:47 PM.
Reply With Quote