In my projects I use the pattern
if [ -f "$path" ] || [ -d "$path" ]; then
echo "$path exists"
fi
to check whether $path exists on the file system, regardless of whether it's a file or directory. Is this exactly equivalent to just doing
if [ -e "$path" ]; then
echo "$path exists"
fi
? What about for special files such as symbolic links or devices? Are there any platform dependent details to be aware of? I use Bash, but I would like to know about subtle differences between shells.