Hi,
How can I use ls command to Delete all files with zero length in a given path using ls command (I guess awk is required!)?
Thanks.
Hi,
How can I use ls command to Delete all files with zero length in a given path using ls command (I guess awk is required!)?
Thanks.
hi,
try this,
ls -l | awk ' { if ($5 == 0) print "rm -f "$9 }' | sh
works very well but why do you use the "| sh" at the end?
Thanks much.
find -maxdepth 1 -type f -size 0 -exec rm -f {} \;
find -maxdepth 1 -type f -size 0 | xargs rm -f
The xargs will cause all the filenames to be sent as arguments to the 'rm -f' commands. This will save processes that are forked everytime '-exec rm -f' is run.
to be robust:
find -maxdepth 1 -type f -size 0 -print0 | xargs -0 rm -f
Thanks guys.