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: 
Beware of filenames starting with '.', normal globbing or using `ls` (*shudder*) will not detect those There are several ways to do this, the simplest I can come up with is:

```
/home/user1> mkdir ini
/home/user1> cd ini
/home/user1/ini> touch .fred jim tom dick harry
/home/user1/ini> cd ..
/home/user1> declare -a names
/home/user1> names=(./ini/* ./ini/.*)
/home/user1> number_of_files=$(( ${#names[@]} -2 ))
/home/user1> echo $number_of_files
5

```

The `-2` is required to remove `.` and `..` from the list.
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"

```