This script shows if a file exit’s or not in a given directory. This can be done using either test command or inbuilt commands such as [ or [[ commands

#Author: Surendra Anne(surendra at
#Purpose: To check if a file exit's or not.
#Date: 2012-07-31
#Modified: ::
read -p "Please enter a file name with full path"
if [ -f $REPLY ]
echo "The file $REPLY exists"
echo "File not found"

We have [ inbuilt command which will do file/folder checking with. So -f is used to check if a file exit's or not.

Save the file as and exit it.

Execute the script

Step1:change permissions to execute permissions as below

chmod +x

Step2: Executing shell script


Please comment your thoughts on this.
The following two tabs change content below.