I\'ve a directory with many number of 0 byte files in it. I can\'t even see the files when I use the ls command. I\'m using a small script to delete these files but sometime
Here is an example, trying it yourself will help this to make sense:
bash-2.05b$ touch empty1 empty2 empty3
bash-2.05b$ cat > fileWithData1
Data Here
bash-2.05b$ ls -l
total 0
-rw-rw-r-- 1 user group 0 Jul 1 12:51 empty1
-rw-rw-r-- 1 user group 0 Jul 1 12:51 empty2
-rw-rw-r-- 1 user group 0 Jul 1 12:51 empty3
-rw-rw-r-- 1 user group 10 Jul 1 12:51 fileWithData1
bash-2.05b$ find . -size 0 -exec rm {} \;
bash-2.05b$ ls -l
total 0
-rw-rw-r-- 1 user group 10 Jul 1 12:51 fileWithData1
If you have a look at the man page for find (type man find
), you will see an array of powerful options for this command.