![]() |
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 |
| Replacing a field in pipe delimited TEXT File | ravi0435 | UNIX for Dummies Questions & Answers | 3 | 01-08-2009 02:54 PM |
| need help with replacing a certain field... | shennanigan83 | Shell Programming and Scripting | 5 | 04-09-2008 02:00 AM |
| replacing a nul field with text | DarkHound | Shell Programming and Scripting | 3 | 09-04-2007 03:34 PM |
| Replacing certain field | charbel | Shell Programming and Scripting | 1 | 04-26-2006 05:00 PM |
| Replacing the last field of a line. | Darek | Shell Programming and Scripting | 3 | 08-19-2005 12:45 PM |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
Supressing and replacing the output of a field in Awk
Wondering if anybody can help with changing the output of a field. I'm needing to change the output of a field in this file:
User Process ID Time Active Licences Type ChangeAdmin (Phys-agsdev/19353 212), start Wed 1/21 6:30 (linger: 1800) u414013 (Phys-agsdev/19353 1491), start Wed 1/21 12:54 (linger: 1800) z001429 (Phys-agsdev/19353 788), start Wed 1/21 13:03 (linger: 1800) u414014 (Phys-agsdev/19353 1009), start Wed 1/21 10:34 z311203 (Phys-agsdev/19353 2368), start Wed 1/21 10:52 u414020 (Phys-agsdev/19353 879), start Wed 1/21 11:43 z311260 (Phys-agsdev/19353 1523), start Wed 1/21 12:17 oracled (Phys-agsdev/19353 555), start Wed 1/21 9:00 u414013 (Phys-agsdev/19353 1717), start Wed 1/21 12:56 The field which says "(linger: 1800)" is field 13. What I want to do is, if it contains "(linger: 1800)", I want it to say "ChangeBase", or if it is blank, I want it to say "CMBase". Here's the code I have, with an if statement, but it has no affect whatsoever! BEGIN { print "User Process ID Time Active Licence Type" } NF > 11{changebaselicences++} NF < 12{cmbaselicences++} { if ($13 == / /) {print "CMBase"} if ($13 ~ /linger/) {print "ChangeBase"} print $4, $6, $7, $8, $9, $10, $11, $12, $13 } END { printf "\nUsers of SYNERGY-ChangeBase: (Total of 11 licenses issued; Total of %-2d", changebaselicences print " licences in use)" printf "\nUsers of SYNERGY-CMBase: (Total of 12 licenses issued; Total of %-2d", cmbaselicences print " licences in use)" } Many thanks in advance. |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|