Peter da Silva wrote: > On 01-Nov-2007, at 18:03, Michael G Schwern wrote: >> $ find . -print0 -name '*.txt' | xargs -0 rm > > That's a mistake.
THANK YOU CAPTAIN OBVIOUS! >> Whoopsie, everything's deleted. 10 gigs of fine public educational >> video, >> gone. Turns out putting -print0 first instead of last causes some >> sort of >> crazy find switch boolean madness to short circuit and everything >> becomes true. > > Nope, the result of the expression is exactly the same as before. > > Consider the difference between "find ... -print -exec something '{}' > ';'" and "find ... -exec something '{}' ';' -print". That sort of "pin the quotes on the expression" game you have to play with -exec that I always get wrong is why I use xargs. > The former prints out all the files it's applying "something" to, so you > know what you somethinged. > > The latter prints out all the files for which "something" succeeded, so > you know what the something files are. > > There's nothing crazy about it at all. It's not a flag, if it was a flag > it would be a single character That you say that like it should be obvious is, in and of itself, crazy. > It's a term in an expression. The hateful > thing isn't that it behaved that way, it's that they put a "-" in front > of the terms in the expression instead of something else like "+" or "=" > so you wouln't think it was some kind of long format option. Bingo. Different things should look different. > They should > have been able to see 15 years into the future and realize that when > people started using versions of getopt (something else that didn't > exist when find was written) that supported long options that people > would decide that find was just doing the same thing. Or, maybe, 15 years later, we'd be using something better than find. -- Just call me 'Moron Sugar'. http://www.somethingpositive.net/sp05182002.shtml