- To: SLUG List <slug@xxxxxxxxxxx>
- Subject: Re: [SLUG] script question
- From: Mike Lake <Mike.Lake@xxxxxxxxxx>
- Date: Mon Jul 30 14:20:02 2001
- User-agent: Mutt/1.2.5i
On Mon, Jul 30, 2001 at 01:50:03PM +1000, Bernhard Luder wrote:
> No, that's not what I mean. I know grep -v will match everything but.
> What I need is:
> if [a log file] does not contain "0% packet loss" specifically then do
> something (eg. restart interface) otherwise do nothing.
> I have no idea how to express this in a command. How will I get a command
> executed, if the log file does not contain "0% packet loss" specifically?
Perhaps I can help with narrowing down what you want algorithmicaly
although not with specific code.
cat logfile | grep -v "0% packet loss"
if this returns a string then that line does not have what we want
sed s/that sring// # this removes the string from the log stream
else
the line in the logfile contains "0% packet loss" so keep it in the stream.
# ie do nothing
done
so what you want is to filter the log stream as above, removing all lines
that dont match "0% packet loss"
Perhaps others can fill in z code.
Mike
--
Ask not for whom the <CONTROL-G> tolls.
Michael Lake, University of Technology, Sydney
Work: Mike.Lake@xxxxxxxxxx Ph: 02 9514 1724 Fx: 02 9514 1628
Home: http://www.speleonics.com.au
Linux enthusiast, active caver and interested in anything technical.
***************************************