Am 09. Jan, 2003 schw=E4tzte Bryce C so: > Hello all. I was wondering if anyone knew how to do an if statement in > bash to see if results were returned? I want to write a bash script to > run hourly that will grep my mailbox for a certain text if the results > are different than the contents of another, previous output, then runn > another command. Somethinng like: > > cat file|grep Text>/tmp/NewText.grep > diff /tmp/NewText.grep /tmp/Text.grep > if( diff returned anything ) ./runme > mv /tmp/NewText.grep /tmp/Text.grep The variable $? has the exit status of the last command. $ grep -q luft /etc/passwd $ echo $? 0 $ grep -q heisseluft /etc/passwd $ echo $? 1 The first grep found something, the second didn't. grep Text file > /tmp/NewText.grep diff /tmp/NewText.grep /tmp/Text.grep >/dev/null if [ $? -ne 0 ] ; then =09./runme =09mv /tmp/NewText.grep /tmp/Text.grep fi ciao, der.hans --=20 # https://www.LuftHans.com/ http://www.TOLISGroup.com/ # A Polish friend of mine got an offer for a free account from AOL. The # login ID was "HELLO" and the passwd "CYMBAL". She says "cymbal" is # Polish for "sucker". "Hello sucker" a greeting from AOHell :).