![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Storing count(*) into unix variable | mervinboyz | Shell Programming and Scripting | 1 | 03-26-2008 08:14 PM |
| Storing a variable? | hoover90 | Shell Programming and Scripting | 4 | 01-26-2008 06:39 PM |
| Using 'defaults read' and storing the output in a variable | davewg | Shell Programming and Scripting | 0 | 11-14-2007 05:04 AM |
| Storing the output into a variable | ravi raj kumar | UNIX for Dummies Questions & Answers | 7 | 12-11-2006 06:14 AM |
| Storing values in variable | matrixmadhan | Shell Programming and Scripting | 1 | 03-31-2005 10:56 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
storing output of awk in variable
HI
I am trying to store the output of this awk command awk -F, {(if NR==2) print $1} test.sr in a variable when I am trying v= awk -F, {(if NR==2) print $1} test.sr $v = awk -F, {(if NR==2) print $1} test.sr but its not working out . Any suggestions Thanks Arif |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
Code:
v=$(awk -F, '{(if NR==2) print $1}' test.sr)
Last edited by jim mcnamara; 05-07-2006 at 01:51 PM. |
|
#3
|
|||
|
|||
|
Here is a script in csh that works.
Notice the back ticks before awk and after the file name , your test file name. It worked fine for me. #!/bin/csh set v=`awk -F, 'NR == 2 {print $1}' test.sr` echo $v >> outputfile "this will append the value of v to a file" Last edited by bdsffl; 05-07-2006 at 12:25 PM. |
|
#4
|
|||
|
|||
|
Thanks everybody for your help ,I got it .
Thanks |
|||
| Google The UNIX and Linux Forums |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|