![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| format the extracted data | kmanivan82 | Shell Programming and Scripting | 2 | 10-15-2008 04:38 PM |
| Sed to format data in a file | cnilashis | UNIX for Advanced & Expert Users | 2 | 08-15-2008 03:37 AM |
| converting a tabular format data to comma seperated data in KSH | Hemamalini | UNIX for Dummies Questions & Answers | 2 | 06-16-2008 05:37 AM |
| data format from (4.56 0.7) -> 4.6(7) awk?! | ahan | Shell Programming and Scripting | 4 | 05-07-2006 09:53 PM |
| format data | inquirer | Shell Programming and Scripting | 2 | 09-24-2003 07:59 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Please help me format this data
STMC429 (192.168.171.72)
2008-11-24 14:18:09.412 softwareupdate[11853] Loading CatalogURL http://creativesus.conair.lan:8088/index.sucatalog No new software available. There are no updates to install STMC444 (3) (192.168.171.116) 2008-11-24 14:14:31.771 softwareupdate[3473] Loading CatalogURL http://creativesus.conair.lan:8088/index.sucatalog There are 1 updates to install STMC604 (192.168.171.48) 2008-11-24 14:13:44.486 softwareupdate[4239] Loading CatalogURL http://creativesus.conair.lan:8088/index.sucatalog There are 1 updates to install STMC606 (192.168.171.113) There are 2 updates to install STMC607 (192.168.23.54) 2008-11-24 14:13:44.457 softwareupdate[4854] Loading CatalogURL http://creativesus.conair.lan:8088/index.sucatalog There are 1 updates to install I only want the STMC# and the amount of updates available if no updates, that machine can be skipped --------------------------------------------------------------------------------------------------------------- Output Should look like: STMC607 1 Extra points for explanation ![]() Thanks! |
|
||||
|
Sure, here we go: Code:
awk '/STMC/{m=$1} m && /^There/ && int($3)>0 {print m, $3}' file
Code:
/STMC/{m=$1}
Store the value of the 1st field (STMCxxx) in the variable m if the line begins with STMC. Code:
m && /^There/ && int($3)>0 {print m, $3}
If m is set and the line begins with There and the 3th field is an integer, print the variable m and the value of the 3th field. Regards |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|