if [ $# -ne 1 ]
then
echo "Usage - $0 file-name"
exit 1
fi
if [ -f $1 ]
then
echo "$1 file exist"
else
echo "Sorry, $1 file does not exist"
fi
Linux / PRACTICAL TUTORIAL
Check if file exists in Shell Script
Advertisement
This shell script demonstrates to check if the given file exists or not.
From the community
No archived comments on this tutorial.