-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.

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 ist eine Bash IDE mit Unterstützung für -eprobieren Sie es aus!
© 2020–2024 Joachim Ansorg
Impressum
Datenschutz
Rechtliches