I have to search a file in a prticular directory. filename will be passed through command line. The directory may contain subdirectory.
i.e.
suppose directory in /u03/appl (it can hard coded in script). This directory may contain subdirectory.
$ scriptname.sh filename
output should be file name if it is there in directory tree.
i've tried some thing but didn't get success. Please help me out
below is code that i had tried
#!/bin/bash
echo $1
if test $# -eq 0 ; then
echo usage: "${0##/*} [Dir name]"
exit
fi
echo 'Search in directory /u03/appl for the $1'
for arg in $* ; do
#if test -e $arg ; then
files=$(ls -lR /u03/appl | grep '[^d]' | awk '{print $9}') # <=
for file in $files ; do
if [[ $1 = $file ]]
then
echo 'got it'
else
echo 'try again'
fi
done
#echo $files
#fi
done
#End