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 sometimes that does not even delete these files. Here is the script:
i=100
while [ $i -le 999 ];do
rm -f file${i}*;
let i++;
done
Is there any other way to do this more quickly?
Use find
combined with xargs
.
find . -name 'file*' -size 0 -print0 | xargs -0 rm
You avoid to start rm
for every file.