find exactly in that directory
I want to use smth . like
if [ -e file ] ;then
statement but I want to know if that file exists under just some given directory(not including its subdirectories) instead of the current directory.I tried
var1=$(find givendirectory -name file)
if [ $var1 != "" ] ;then
but of course that did not work because
1) find givendirectory -name file command does not search in only the given directory,it also looks in the subdirectories of it.
2) $var1 is never "" because if the file does not exits , the command does not substitude ""
to var1 ,it substitudes "find: he: No such file or directory"
is there a practical way to search under a given directory for whether a file exists?
pass given directory as param1 and filename to param2
./blah.sh dir file
|All times are GMT -5. The time now is 01:22 PM.|