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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

The test command with -a, !, and -o operators? 1

Status
Not open for further replies.

goldenradium2001

Technical User
Mar 22, 2002
91
US
Can anyone give me a good example of how these work?

 
Sorry I misunderstood

It's

file1 exists

test file1
if [ $? -eq 0 ];then
echo "file1 exists"
fi

file1 exists an file2 doesn't

test file1 -o file2
if [ $? -eq 0 ];then
echo "one file at least exists"
fi


file1 exists an file2 doesn't

test ! file1 -o ! file2
if [ $? -eq 1 ];then
echo "one file at least doesn't exist"
fi


! negation operator
-a binary and operator
-o binary or operator

EDC
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top