Discover and Optionally Delete Files with Find Command

Posted September 4, 2003 by Quinn McHenry in UNIX

Last Updated on

How to discover files matching a find condition and delete them upon user confirmation.

To find all files with zero length and ask if they should be deleted:

find / -size 0 -ok rm {} \;

The backslash \ is important because it tells the shell to ignore the semicolon symbol which usually separates commands on a single command line.


About Quinn McHenry

Quinn was one of the original co-founders of Tech-Recipes. He is currently crafting iOS applications as a senior developer at Small Planet Digital in Brooklyn, New York.
View more articles by Quinn McHenry

The Conversation

Follow the reactions below and share your own thoughts.

Leave a Reply