You are not logged in.
How to make an "if" statement checking if a directory is not empty.
Something like....
if [ `ls /test/*` !="" ]; then
echo "not empty"
fi
Markku
Offline
if[ 'ls /dir/*' !="ls: /dir/*: No such file or directory" ]; then
echo "not empty"
fi
Offline
if [ `ls -A1 /test/ |wc -l` -gt 0 ]; then
echo "directory is not empty"
fi
Offline
Thanks Penguin. Atxe's solution gave an error:
bash: [: ls test/*: unary operator expected
Markku
Offline