![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | 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 and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Help needed please. | jerryboy78 | UNIX for Dummies Questions & Answers | 3 | 03-16-2008 02:06 PM |
| Scp Help Needed !!!! | scooter17 | UNIX for Dummies Questions & Answers | 3 | 09-20-2006 12:50 PM |
| Cut help needed!!!!!! | scooter17 | UNIX for Dummies Questions & Answers | 1 | 08-15-2006 10:41 AM |
| cut help needed!!!!! | scooter17 | UNIX for Dummies Questions & Answers | 4 | 08-15-2006 08:48 AM |
| Help needed | Toxic | Shell Programming and Scripting | 9 | 03-18-2006 03:52 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
awk help needed
How do I alter this command so that it prints only the second comma delimited field from line number 3? Secondly, how do you redirect the output to a variable called TEST?
Thanks (cat BATCH007.TXT | awk 'BEGIN { FS = "," } ; {print $2 }') |
|
||||
|
the 'head -2' pulls the top two lines of the text file, the 'tail -1l' pulls the bottom of those 2, so it's the second line of the file. Yogesh's method is cleaner and doesn't require external unix commands, but I couldn't remember the awk variable to get the current row number..
|
|
||||
|
Shorther:
Code:
TEMP=$(awk -F',' 'NR==3{print $2}' BATCH007.TXT)
|
| Sponsored Links | ||
|
|
![]() |
| Bookmarks |
| Tags |
| awk variables, unix commands |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|