The UNIX and Linux Forums  

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




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #4 (permalink)  
Old 11-24-2008
Franklin52 Franklin52 is online now Forum Staff  
Moderator
  
 

Join Date: Feb 2007
Posts: 4,348
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