The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



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 03:38 PM
Sed to format data in a file cnilashis UNIX for Advanced & Expert Users 2 08-15-2008 02:37 AM
converting a tabular format data to comma seperated data in KSH Hemamalini UNIX for Dummies Questions & Answers 2 06-16-2008 04:37 AM
data format from (4.56 0.7) -> 4.6(7) awk?! ahan Shell Programming and Scripting 4 05-07-2006 08:53 PM
format data inquirer Shell Programming and Scripting 2 09-24-2003 06:59 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 11-24-2008
glev2005 glev2005 is offline
Registered User
  
 

Join Date: Oct 2008
Posts: 74
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!
  #2 (permalink)  
Old 11-24-2008
Franklin52 Franklin52 is offline Forum Staff  
Moderator
  
 

Join Date: Feb 2007
Posts: 4,293
Something like this?

Code:
awk '/STMC/{m=$1} m && /^There/ && int($3)>0 {print m, $3}' file
  #3 (permalink)  
Old 11-24-2008
glev2005 glev2005 is offline
Registered User
  
 

Join Date: Oct 2008
Posts: 74
Pretty awesome Franklin.. care to explain it?
  #4 (permalink)  
Old 11-24-2008
Franklin52 Franklin52 is offline Forum Staff  
Moderator
  
 

Join Date: Feb 2007
Posts: 4,293
Quote:
Originally Posted by glev2005 View Post
Pretty awesome Franklin.. care to explain it?
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
  #5 (permalink)  
Old 11-24-2008
glev2005 glev2005 is offline
Registered User
  
 

Join Date: Oct 2008
Posts: 74
Brilliant, I need to learn AWK!!!
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 09:47 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0