I am writing a shell script and I am calling wc -l. I need to assign the results of this call to a varaible and it's not working the way I think it should:
xx= wc -l $1
What am I doing wrong?
Thanx
I am writing a shell script and I am calling wc -l. I need to assign the results of this call to a varaible and it's not working the way I think it should:
xx= wc -l $1
What am I doing wrong?
Thanx
Well, if you want the results of this call to be assigned to the variable, you shoud use the "command substitution" operator, which is the backquote " ` ". Note that it's not " ' ".
Also, when assigning values to variables, you should use "=" without spaces before and after.
So, it would be:
xx=`wc -l $1`
Have fun!