When you write a shell script and you want to find the file name is already exist in specific directory we can found using simple IF condition,

Find Single File is Exist?

For example i whould like to find the file name is "thelinuxfaq.txt" under root directory,


#!/bin/bash
if [ ! -f /root/thelinuxfaq.txt ]; then
    echo "The File not Found !!!"
fi


Read File Name and Find in Root Path

 #!/bin/bash
echo "Enter The File Name:"
read FILE_NAME

if [ ! -f /root/$FILE_NAME ]; then
    echo "The File not Found !!!"
fi


How to Find Multiple Files are Exist in different location?


 #!/bin/bash
if [  -e  "/root/thelinuxfaq.sh"  -a  -e "/root/thelinuxfaq.html"  -a  -e  "/tmp/thelinuxfaq.txt"   ]
then
echo "Files are exist"
else
echo "Files can not be found"
fi