Actually i need to satisfy both the condition..
lik i'm lookin for two different files.. and if BOTH the files r not present then it should run the followin script.. For example
inputfile1=data/in/inputfile1.txt
inputfile2=data/in/inputfile2.txt
if [ ! -f ${inputfile1} && ! -f ${inputfile2} ]
then
echo " "
echo "ERROR: Files not found."
echo " "
exit 1
fi
echo " "
echo "RUN SUCCESSFUL: Both Files found. "
echo " "
exit 1
Here even if the second file is not present its showing RUN SUCCESSFUL.. Please Help...
aigles
April 25, 2008, 9:01am
2
Replace && by -a
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
jean-Pierre.
Just shorter..
#!/bin/sh
inputfile1=data/in/inputfile1.txt
inputfile2=data/in/inputfile2.txt
[ -f ${inputfile1} -a -f ${inputfile2} ] && echo OK || echo NOK
push
April 25, 2008, 9:09am
4
Simple Mistake
You can use && if u use like
in your code
push
April 25, 2008, 9:09am
5
Simple Mistake
You can use && if u use like
in your code
push
April 25, 2008, 9:11am
6
sorry didnt see the replies
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