Posts Tagged ‘test’

Test if a directory is empty in Bash

Posted: 29th January 2015 by Tim in Bash, Linux
Tags: , , , , , ,

Using Bash, there are a number of ways to test if a directory is empty. One of those ways is to use ls -A to list all files, including those starting with . and see if anything is printed. This can be done like so: if [ ! “$(ls -A <path>)” ] then     echo “<path> […]