Question: > 
> **Possible Duplicate:**  
> 
> [Checking if a directory contains files](https://stackoverflow.com/questions/91368/checking-if-a-directory-contains-files) 
> 
> 
> 

I want to see if a directory is empty, so I am using `[` as follows:

```
[ -f "./ini/*"]

```

And the return value is always 1, even though the directory is not empty.
Any ideas what's wrong?

Answer: 
If the output of the command below is `0` then no files in directory (Directory empty) else it has files!

```
$find "/path/to/check" -type f -exec echo {} \;|wc -l

```

so for you -

```
exist=`find "./ini" -type f -exec echo {} \;|wc -l`
if [ $exist -gt 0 ]
then
   echo "Directory has files"
else
   echo "Directory is empty"
fi

```

Or

```
if [ `find "./ini" -type f -exec echo {} \;|wc -l` -gt 0 ]
then
   echo "Directory has files"
else
   echo "Directory is empty"
fi

```
This works for me 

```
[ "$(ls -A /path/to/directory)" ]

```

in your case it would be

```
[ "$(ls -A ./ini/)" ]

```

you can test it using 

```
[ "$(ls -A /tmp)" ] && echo "Not Empty" || echo "Empty"

```