![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| problem with if, while, for conditions | kittusri9 | Shell Programming and Scripting | 3 | 04-24-2008 09:15 AM |
| reduce the or conditions | hitmansilentass | Shell Programming and Scripting | 8 | 05-03-2007 05:27 PM |
| multiple conditions in if/then | grandtheftander | UNIX for Dummies Questions & Answers | 4 | 07-21-2006 01:58 PM |
| if statement with two conditions | cin2000 | Shell Programming and Scripting | 1 | 01-23-2006 03:21 PM |
| if statement with two conditions -e, && | yongho | Shell Programming and Scripting | 16 | 06-14-2005 04:46 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|||||
|
Replace && by -a
Code:
inputfile1=data/in/inputfile1.txt
inputfile2=data/in/inputfile2.txt
if [ ! -f ${inputfile1} -a ! -f ${inputfile2} ]
then
echo " "
echo "ERROR: Both files not found."
echo " "
exit 1
fi
if [ ! -f ${inputfile1} -o ! -f ${inputfile2} ]
then
echo " "
echo "ERROR: File(s) not found."
echo " "
exit 1
fi
echo " "
echo "RUN SUCCESSFUL: Both Files found. "
echo " "
exit 0
Last edited by aigles; 04-25-2008 at 09:02 AM.. Reason: 'exit 0' is a better choice for successful execution |
|
||||
|
Just shorter..
Code:
#!/bin/sh
inputfile1=data/in/inputfile1.txt
inputfile2=data/in/inputfile2.txt
[ -f ${inputfile1} -a -f ${inputfile2} ] && echo OK || echo NOK
Last edited by danmero; 04-25-2008 at 09:09 AM.. Reason: remove not |
|
||||
|
Simple Mistake :-)
You can use && if u use like Quote:
Quote:
Last edited by push; 04-25-2008 at 09:10 AM.. Reason: wrong code |
|
||||
|
shorter form :
inputfile1=data/in/inputfile1.txt inputfile2=data/in/inputfile2.txt [ ! -f ${inputfile1} -a ! -f ${inputfile2} ] && { echo "\n ERROR: Both files not found. \n" ; exit 1 ;} [ ! -f ${inputfile1} -o ! -f ${inputfile2} ] && { echo "\n ERROR: File(s) not found. \n" ; exit 1 ;} echo "\n RUN SUCCESSFUL: Both Files found. \n" exit 1 |
| Sponsored Links | ||
|
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|