Hi,
i am declared if statement like:
#!/usr/bin/ksh
if ! ls "${LOGDIR}/xxx.dat" ; then
echo "LOG NOT FOUND"
exit 1
else
;
### call another script
abc.sh.
;
;
;
fi
but the stament not working properly.
the echo message disply since file(xxx.dat) not in directory.
i want ruu the script when the file(xxx.dat) has found in {LOGDIR} directory.
Inorder to check the availability of the file,you may use
-f option[ True if filename exists and is a regular file.] ref. man test ...
someting like this
if [ -f filename ]
then
...
else
...
fi
Buddy,
Please refrain yourself from coding in such a way. There are many options in Unix to check whether the file is present in the directiory or not. Please check the below code snippet:
if [-f "$LOGDIR/xxx.dat"];then
#Call your shell script now with the parameters, if any.
abc.sh
else
echo "LOG NOT FOUND"
exit 1
fi
I have just elaborated the point what my friend ShivDatta has already mentioned. Probably, this will help you out.