check if a directory is empty or not in shell script
Give a directory path and check if it contains any files or not.
[code language=”shell”]
#!/bin/sh
DIR=’/a/path/to/a/directory/’
if [ "$(ls -A $DIR)" ]; then
echo "$DIR is not empty"
else
echo "$DIR is empty"
fi
[/code]
Search within Codexpedia

Custom Search
Search the entire web

Custom Search
Related Posts