Ho to assign the value of awk command to a variable in unix script

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Ho to assign the value of awk command to a variable in unix script

reenak
Hi ,

I need to assign the value of a awk to a variable.

I have tried like this

s = `echo "$line" | awk '{print $2}'`

but its considering $2 as a command line argument and throwing error as 'Second argument is needed'

can anyone help me?


Reply | Threaded
Open this post in threaded view
|

Re: Ho to assign the value of awk command to a variable in unix script

Guru
Administrator
The command looks fine(except for the spaces before and after '=' which should not be there). If you are still facing the issue, can you please show the output of the "echo $line" and then your command output as well?