shell script….find file in any directory


this script can be use to search file .
just give directory and file name .
it will print whether that file exists or not
for current directory just press “Enter” to give directory
here’s the script

#!/bin/bash
#run this script to search any file in DIRECTORY U HAVE INPUT
#MAKE SURE UR DIRECTORY IS CORRECT
#FILE NAME SHOULD BE CORRECT
#BS -25/03/12
echo enter dir
read dir
cd $dir
echo enter filename
read user
if [ -d $dir ]
then
for file in *
do
if [ -f $user ]
then
echo $user exists in $dir
break
else
echo $user doesnt exists in $dir
break
fi
done
else
echo enter correct dir
fi
exit 0

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s