0

why does not work this condition?

if [ -d /home/virt -a $(ls -A /home/virt/) = 0 ]

Exists of directory /home/virt AND check if the directory is /home/virt/ empty

Thank you...

Charlie
  • 2,061
  • 4
  • 21
  • 21
  • 1
    look at the output of `ls -A /home/virt/` when it's NOT empty ... OR for that matter if empty, then result is equiv to "", not 0. Won't work. Good luck. – shellter Aug 30 '12 at 17:07

1 Answers1

2
if [ -d $1 -a $(ls -A $1 | wc -l) == 0 ]; then
  echo EMPTY
fi
perreal
  • 94,503
  • 21
  • 155
  • 181