![]() |
|
|
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 |
| how to access values of awk/nawk variables outside the awk/nawk block? | saniya | Shell Programming and Scripting | 5 | 05-13-2008 08:37 AM |
| How to use awk instead of nawk? | kinmak | UNIX for Dummies Questions & Answers | 2 | 05-07-2008 05:34 AM |
| nawk & awk | sd12 | UNIX for Advanced & Expert Users | 5 | 05-05-2008 11:46 AM |
| nawk/ksh help | DeltaX | Shell Programming and Scripting | 0 | 03-06-2008 03:54 PM |
| nawk use | ctap | UNIX for Advanced & Expert Users | 2 | 01-17-2008 06:45 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
nawk help
What am I doing wrong here? I get syntax error.
I am trying to parse a file looking for the lines with "running" as the first field then print the 5th field, then looking at the 9th field for specific values and writing the whole line to a junk file. nawk '; {if ($1 == "running") print $1 >> ./junk1; if ($9 == "S73isid") {print $0} >> ./junk1; if ($9 == "S750vxpal.gridnode") {print $0} >> ./junk1; if ($9 == "S75vxpal.StorageAgent") {print $0} >> ./junk1; if ($9 == "S75vxsmfd") {print $0} >> ./junk1; if ($9 == "S760vxpal.actionagent") {print $0} >> ./junk1; print}' rc2.d_listing Thanks!! |
|
||||
|
Ran it got this??
/tmp/wbe]# nawk -f bep.awk rc2.d_listing > ./junk1 nawk: newline in string S73isid S7... at source line 2 context is n=split("S73isid S750vxpal.gridnode S75vxpal.StorageAgent S75vxsmfd S760vxpal. >>> <<< nawk: newline in string , list) S7... at source line 3 nawk: syntax error at source line 4 missing ) |
|
|||||
|
Quote:
|
|
||||
|
OK fixed the syntax error but
what I was hoping for is something like this IP address (Field 5) then the "S" Files ie: 196.196.1.10 S* 196.196.1.10 S* 196.196.1.10 S* 196.196.1.10 S* 196.196.1.11 S* 196.196.1.11 S* 196.196.1.11 S* 196.196.1.11 S* |
|
|||||
|
Quote:
In your original code you're outputting the ENTIRE line (print $0) if the NINTH field is one of the matched strings. And I think you wanted to output the 5-th field if the frst field is 'running'. This is what I coded based on your explanation and a piece of code you've given. If want you can provide a sample data file, a desired output and a description (once again) of what you're trying to achieve. Please use vB Codes when posting any data samples. |
|
||||
|
Sorry for the misunderstanding!!
S* Stands for S73isid S750vxpal.gridnode S75vxpal.StorageAgent S75vxsmfd S760vxpal if "running" output 5th field then if a match on the 9th field print the whole line is OK I am getting the whole line and that is fine I just never get the 5th if running is 1st field.. Thanks!!!! |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|