Check file existence
You check file existence using test command.
if test ! -s "dirname/filename"
then
echo "File does not exist"
else
echo "File exists"
fi
Here is the alternative way to check file existence. You can also check for multiple files
if [ -f dirname/filename1 ] && [ -f dirname/filename2 ]
then
echo "File exists"
else
echo "File does not exist"
fi
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home