Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

group lines

Status
Not open for further replies.

aasislopez

IS-IT--Management
Aug 8, 2012
1
ES
Dear all,

I wonder how awk can order by group (first colum) and show only group(s) if all lines of the group have NOK as second field.

Input:
AND OK
AND NOK
AND NOK
VAL OK
VAL OK
VAL OK
MAD NOK
MAD NOK
MAD NOK

Output:
MAD NOK
MAD NOK
MAD NOK

Many thanks,

 
Your sample output doesn't match your stated requirements. By your own sample data, your output for all "NOK" in the second field should be:

AND NOK
AND NOK
MAD NOK
MAD NOK
MAD NOK

So, if this is truly the out put you desire...

root@linux:~# cat sort.txt | awk '$2 == "NOK"'
AND NOK
AND NOK
MAD NOK
MAD NOK
MAD NOK
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top