xargs / FS-maintenance question

Fraser Campbell fraser-eicrhRFjby5dCsDujFhwbypxlwaOVQ5f at public.gmane.org
Fri Oct 1 20:14:28 UTC 2004


On Friday 01 October 2004 15:30, Lennart Sorensen wrote:

> Just be aware the example fails badly on filenames with spaces.  For
> that you should use find's -print0 option along with xarg's -0 option.
> Null seperated filenames rahter than whitespace seperated.

I'm sure y'all know this but just a quick tip to save the fast fingered ...

print0 is a very useful option, it is also a dangerous option for someone who 
might skim the man page without grokking it 100% ... like me ;-)

"find . -type f -mtime +7" will print all files that have not been modified in 
at least 7 days.

"find . -type f -print0 -mtime +7" will print all files.  -print0 must be the 
last arument, very important when doing something like:

   find . -type f -mtime +7 -print0 | xargs -r -0 rm -f

Fortunately there were backups in my case :-(

-- 
Fraser Campbell <fraser-Txk5XLRqZ6CsTnJN9+BGXg at public.gmane.org>                 http://www.wehave.net/
Georgetown, Ontario, Canada                               Debian GNU/Linux
--
The Toronto Linux Users Group.      Meetings: http://tlug.ss.org
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://tlug.ss.org/subscribe.shtml





More information about the Legacy mailing list