Bash Scripting Help

Kevin Brown plug-discuss@lists.plug.phoenix.az.us
Thu, 09 Jan 2003 19:01:52 -0700


Bryce C wrote:
> 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
> 
> I just don't know what if switches are available (to use) in bash.
> Thank you.
> 
Here's a sample bash script I wrote:

SIZE=`ls -l $HOME | grep tvguide.all.html | awk '{ print $5 }'`
GT=`expr $SIZE \> $MINSIZE`
if [ "$GT" -eq 1 ]
then
   mv -f ./tvguide.all.html $DEST/tvguide.all.html
fi