-s FILE (conditional operator)

true if the file exists and is not empty, i.e. has a size greater than zero.

Examples

Different ways to test if a file is not empty:
1
2
3
4
test -s ~/file && echo "not empty"
[ -s ~/file ] && echo "not empty"
# Bash
[[ -s ~/file ]] && echo "not empty"
BashSupport Pro is a Bash IDE with support for -stry it now!
© 2020–2024 Joachim Ansorg
Imprint
Privacy Policy
Legal