-e FILE (conditional operator)
true
if the file exists.
It doesn’t matter if FILE
refers to a directory, a file, or something else like a block
device.
This is the same as -a FILE
.
Links
Examples
- Different ways to test if a file exists:
1 2 3 4 5 6 7
test -e /opt && echo "exists" test -e /opt/file.txt && echo "exists" [ -e /opt ] && echo "exists" [ -e /opt/file.text ] && echo "exists" # Bash [[ -e /opt ]] && echo "exists" [[ -e /opt/file.txt ]] && echo "exists"
BashSupport Pro is a Bash IDE with support for -e – try it now!