$ find "/tmp" -type f -exec echo Found file {} \;
Found file /tmp/_.c
Found file /tmp/orbit-vivek/bonobo-activation-server-ior
...
2. The simplest and most effective way is to use ls with -A:
$ [ "$(ls -A /directory)" ] && echo "Not Empty" || echo "Empty" # Or
FILE=""
DIR="/tmp"
# init
# look for empty dir
if [ "$(ls -A $DIR)" ]; then
echo "Take action $DIR is not Empty"
else
echo "$DIR is Empty"
fi
# rest of the logic
No comments:
Post a Comment