2016-10-14 07:08:22 +0700, Peter & Kelly Passchier:
> WHich docs?
> If I do "help test" it states: "All file operators except -h and -L are
> acting on the target of a symbolic link, not on the symlink itself, if
> FILE is a symbolic link."

Yes, to test for file existence, the syntax is

[ -e "$file" ] || [ -L "$file" ]


ls -d -- "$file" > /dev/null 2>&1

But even then, if it returns false, that doesn't necessarily
mean the file doesn't exist. It could also be that it's
impossible to tell. If you remove the 2>&1 above, the error
message would help you differentiate between the cases.

If using zsh instead of bash, you can also check the $ERRNO
variable to see if [ -e ] failed because of ENOENT or something

See also 


Reply via email to