Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Troubleshooting
Research
Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

AWK/GREP combination question

Avatar of TwentyFourSeven
TwentyFourSeven asked on
Shell Scripting
6 Comments1 Solution402 ViewsLast Modified:
Hello,

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

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 ?

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.