Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multiple condition in "IF"

Status
Not open for further replies.

nithink

Programmer
Nov 7, 2002
92
US
Hi, I'm using Bourne shell and i want to check multiple condition in an if statement using 'OR'. I need to check 2 directories for a particular file. If not found I've to do send mail.

if [ ! -f [ /home/dir_1/$filename -o /home/dir_2/$filename ] ]
then
mail xyz
fi

It didnt give any syntax error but didnt work as desired. Can anyone pls let me know the correct syntax.

Thanks
 
Hi:


This seems to work on my Solaris 7 box:

#!/bin/sh

if [ ! -f dir_1/f -o ! -f dir_2/f ]
then
echo "no f file"
fi

Regards,


Ed
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top