On Fri, Jul 16, 2010 at 08:05:15AM +1000, Cameron Simpson wrote: >I'm sorry I'm late to this discussion - you guys seem to have a grep >obsession :-) > >On 14Jul2010 23:12, Roger <[email protected]> wrote: >| On Thu, Jul 15, 2010 at 08:06:17AM +0200, David Haguenauer wrote: >| >* [email protected] <[email protected]>, 2010-07-14 21:01:01 Wed: >| >> How can I exclude one folder from my mailbox list using a find >| >> pipe? >| >> >| >> muttrc: >| >> mailboxes `find ~/.maildir/ -type d -name cur -printf '%h '` >[...] >| > >| >I'd use grep; something like the following: >| > >| > find ~/.maildir/ -type d -name cur -printf '%h ' | grep -v '\.roger/' >| > >| >(Adapt the regexp depending on how strict you need to be.) >| >| Great THANKS! I think this one worked "right out of the box, as is". >| >| I spent hours looking at man find, google, etc and none worked and I thought >| grep -v wouldn't work. >[...] >| I think I'll post the grep -v option to the Mutt Wiki ConfigTricks! > >Maybe not. > >Isn't this more direct? > > find ~/.maildir/ -type d \( -path ~/.maildir/.roger -prune -o -name cur > -printf '%h ' \)
Yup. This incantation works as well! >It also avoids regexps, which are often annoying (escaping . to \. etc). > >You can also speed it up greatly by pruning the search when you hit the >"cur" or "new" folders, otherwise find will walk all the messages as >well looking for deeper trees: > > find ~/.maildir/ -type d \( -path ~/.maildir/.roger -prune -o -name cur > -printf '%h ' -prune -o -name new -prune \) > >which can be written: > > find ~/.maildir/ -type d \( -path ~/.maildir/.roger -o -name cur -printf '%h > ' -o -name new \) -prune > >And are your maildirs all at the top level, or are they deeper? >If you have a nested tree structure (I do - my old archived email is in >subtrees) you need find. >But if it is just a flat directory (.maildir/a, .maildir/b) you don't >need find at all! Just use echo! > > echo ~/.maildir/* > >or > > for name in ~/.maildir/*; do case "$name" in */.roger) ;; *) echo "$name" ;; > esac; done > >Which should be faster than find (no directory tree walking at all). > >Cheers, > >Every particle continues in its state of rest or uniform motion in a straight >line except insofar as it doesn't. - Sir Arther Eddington The rest is interesting, yup, no subfolders here. It's interesting how the obvious solutions stare us blankly in the face. I have been using echo (per wiki), but completely overlooked a "for/next" incantation, grappling with find. Cheers! -- Roger http://rogerx.freeshell.org/
