Hi Gurus,
I have a directory A, which has some 0 byte files in it.
This directory also has a subdirectory B which also has some 0 byte files in it.
The problem:
I only need to find out the names of the 0 byte files in the directory A.
I'm using the following command
find . -name *.zip -size 0c
This command not only lists the 0 byte files within dorectory A , but also lists the 0 byte files within directory B.
./x001_ameint_BP010F0010_00264_001.zip
./B/x001_ameint_DV010F0065_00264_001.zip
how to get only the 0 byte files in current directory but not in its sub directories.
Please help
thanks
Ram.
You can add the -maxdepth switch to find and set it to 1:
-maxdepth 1
Hope this helps.
joeyg
3
skip subdirectories the begin with letter B
find . B* -prune -name *.zip -size 0c
limit to no subdirectories
find . -maxdepth 1 -name *.zip -size 0c
thanks for the reply...
but here is what i get when i use maxdepth
find . -maxdepth 1 -name *.zip -size 0c
find: bad option -maxdepth
find: path-list predicate-list
If your find version don't support the -maxdepth option or you have many subdirectories to exclude you can do something like:
ls -l *.zip | awk '$5==0'
find . -name "*.zip" -size 0c -name "dirB" -prune
-maxdepth is a GNU find option. POSIX find doesn't have it - yet. So a lot of unix boxes do not have it
-prune is good.