Lists/Remove all empty files in a directory

 

To list all empty files in a directory use follwoing command:

for file in `ls`; do if [[ ! -s $file ]]; then echo $file; fi; done

To remove all empty files in a directory use following commad:

for file in `ls`; do if [[ ! -s $file ]]; then echo $file; rm $file; fi; done

Leave a comment