Operating System - HP-UX
1748060 Members
6011 Online
108758 Solutions
New Discussion

Shell script and test for empty directory

 
Coolmar
Esteemed Contributor

Shell script and test for empty directory

Hi,

I need a test condition for an empty directory. I will have a cron that will watch a certain directory and when there are files in there (name will always vary) they will be moved somewhere else. I just can find a test condition for empty directory or files present in a directory.

Thanks!
1 REPLY 1
Coolmar
Esteemed Contributor

Re: Shell script and test for empty directory

Decided to work around it with

if [ `ls -a |wc -l` -gt 2 ]; then

Thanks