Tugger the SLUGger!SLUG Mailing List Archives

[SLUG] Re: script question - SOLVED


\begin{Bernhard Luder}
> Thanks everyone for their help. Your answers brought me a huge step forward
> in the effective automation on my network.
> 
> I ended up using something along the lines of (Thanks Rick and Russell):
> 
> if ! grep "0\% packet loss" file; then command; fi

1. if you're only interested in the exit status, not the actual
   matching lines, use "grep -q".  no point searching the entire file
   when the first line matches.

2. use "grep -q '0% packet loss' || command".  its a very common idiom
   in shell scripting, you'll see it all over the place.  shell is not
   C, the quicker you embrace its differences, the sunnier life will
   be.

-- 
 - Gus.terse