Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Find can exec commands too' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Find can exec commands too
Authored by: jpbjpbjpbjpb on May 24, '05 01:38:34PM
FYI, find can do the rm for you as well, you don't need to pump the find output into a script.

find ~/Library/Mail -path "*.imapmbox/Cached*" -exec rm -v '{}' ';'

find ~/Library/Mail -path "*.mbox/mbox" -exec rm -frv '{}' ';'

find ~/Library/Mail -path "*.*mbox/content_index" -exec rm -frv '{}' ';'

find ~/Library/Mail -path "*.mbox/table_of_contents" -exec rm -frv '{}' ';'


[ Reply to This | # ]
Find can exec commands too
Authored by: zojas on Jun 02, '05 02:23:43AM
even better, use xargs. the -exec flag does a fork for each and every file. (i.e., a new process is launched for each file!)

with xargs, there will only be the find process, the xargs process, and a few rm processes (eventually the command line to rm will get too long and xargs will have to launch another rm).

when you have an imap inbox with 9000 messages in it like I do it's a big deal. I ran the first find without removing the files, just piping the list of files to 'wc' to see how many there were. there were 20560 files! In my case, I'll get about 20 processes launched using xargs, as opposed to 20561 if I use the -exec flag.

try this:

find ~/Library/Mail -path "*.imapmbox/Cached*" -print0| xargs -0 rm
find ~/Library/Mail -path "*.mbox/mbox" -print0 | xargs -0 rm -frv
find ~/Library/Mail -path "*.*mbox/content_index" -print0 | xargs -0 rm -frv
find ~/Library/Mail -path "*.mbox/table_of_contents" -print0 |xargs -0 rm -frv

(the -print0 and -0 arguments are just to take care of files with spaces in the name; they are 'zeros' not 'ohs')

the first find command (which deleted 20000 files) only took 48seconds on my 700Mhz g3 ibook.

before deleting all those files, my ~/Library/Mail was 1.3G, afterwards it was only 677MB.

and mail.app still works fine, so those seem to be the correct files to delete.



[ Reply to This | # ]

Find can exec commands too
Authored by: Kalak on Jul 07, '05 11:52:10AM

I'm been using find and exec for a while now, but I didn't know that xargs forked once (generally). I'll have to try to get used to using it instead, and I know the overhead for some of the find -exec commands I've run is noticable, so this should save a lot.

---
--
Kalak
I am, and always will be, an Idiot.



[ Reply to This | # ]