This is probably a stupid question to ask. But could somebody help me clearly distinguish the difference between these two operators in unix '==' and '='?
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!
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:
Last edited by Corona688; 05-20-2006 at 03:47 AM..
Thanks both of you, for your replies. The examples that I cited were from ksh actually. I did come across some places and found out that == is equality operator used in arirthmatic operations (e.g. to compare two strings) whereas = is simply an assignment operator.
I guess I am still a little bit confused as far as the different brackets are concerned i.e. is my understand correct per following:
1. (commands...) - open a subshell and execute commands in that subshell ??
2. ((commands...)) - i have no idea about this one.
As far as [ $var1 -eq 0 ] and [[ $var1 -eq 0 ]] type of brackets are concerned, i guess they are equivalent and are used to test whether var1 is set to 0.
In the awk I am trying to subtract the difference $3-$2 of each matching $4 before the first _ (underscore) and print that value in $13.
I think the awk will do that, but added comments. What I am not sure off is how to add a line or lines that will add sum each matching $13 value and put it in... (2 Replies)
Hi ..
I am trying to create one function.
It will have two arguments.
Argument1: a,b,d,f,g
Argument2:21212,sfsd,4546,67867,a,asda,b
So the output will be Argument1 - Argument2
which is d,f,g
Can anyone help with this one? (4 Replies)
I think both write at the end of the file ......
but is there a sharp difference between those 2 instruction .....
thank you
this is my 3rd question today forgive me :D (1 Reply)
just wondering what the difference is between 1,$ and /g when doing a substitution in vi. doesn't seem to be much difference from what i can see. (2 Replies)
Hello
I would like to know where there is a difference between these two machines?
HP9000-735/125
HP9000-B132L
What does that all mean?
Okay, HP= Hewlett Packard
But 9000, 725/125, B132L ????
I am asking that question because I am about to buy one for myself, so I can have some fun... (3 Replies)