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

Help with IF

Status
Not open for further replies.

RJSHA1

Programmer
Apr 12, 2001
66
GB
Hi guys,
Can I do some thing like this. I want to do an IF where I check if a a variable OPTION = JHA2 and if a file exist and has a size greater than zero

if [ $OPTION = JHA2 -a -s sbs3000$OPTION.dis ];


Would this work or have I missed something
 
Have you tried it? It would *almost* work.
Code:
if [ $OPTION = "JHA2" -a -s sbs3000$OPTION.dis ]
then
   ...
   ...
fi
Greg.
 
?

if $OPTION has to equal a specific value then
why not just use that specific value.

if [ -s svs3000JHA2.dis ]

or if you are testing the value of a variable then you
should protect against a null value

if [ x$OPTION = "xJHA2" -a -s svs3000$OPTION.dis ]

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top