Programming Tutorials

Check if file exists in Shell Script

By: Vivek G in Linux Tutorials on 2011-01-29  

This shell script demonstrates to check if the given file exists or not.
 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





Add Comment

* Required information
1000

Comments

No comments yet. Be the first!

Most Viewed Articles (in Linux )

Latest Articles (in Linux)