Question : AWK/GREP combination question

Hello,

Assuming I've got an output similar to the following to parse :

1:
2:
3:
One      12345      Connected
Two      67890      Connected


My questions are as folllows :

(1) I would like to display only rows where column 3 status has changed.  "grep -v" is too coarse, it looks at entire rows,  and "awk {print $3} | grep -v" doesn't do the job of outputting whole rows.    Unfortunatley my shell coding expertise is limited to know of other options !

(2) What is an efficient way of continuing the script if there is output from the above ?

1:
2:
3:
4:
5:
6:
count =  `  some piped commands | wc -l `
if [$count -gt 0]
then
 do something
fi


The above does not seem very efficient, because I would need to call the piped command again in order to be able to use its output.  

Answer : AWK/GREP combination question


command | awk '$3!~"Connected"  {print}'  | while read line
  do
    echo $line | mailx -s 'Lines other than "Connected" found!' [email protected]  
  done

The above will do "nothing" (not send out mail) if no matching lines are found.

wmp

Random Solutions  
 
programming4us programming4us