I’m using the find command in my bash script like so
for x in `find ${1} .....`;
do
...
done
However, how do I handle the case where the input to my script is a file/directory that does not exist? (ie I want to print a message out when that happens)
I’ve tried to use -d and -f, but the case I am having trouble with is when ${1} is “.” or “..”
When the input is something that doesn’t exist it does not enter my for loop.
Thanks!
Bash scripting is a bit weird. Practice before implementation. But this site seems to break it down well.
If the file exists, this works:
If the file does not exist, this works. Note the ‘!’ to denote ‘not’: