News for hackers. Stuff that matters.
Re:Find is a beautiful tool by parfe on Sunday July 24, 2011 @10:41AM (#2799461)
find -delete -name ".pyc" is not the same as find -name ".pyc" -delete

First one nukes everything including the git repo

Second does what I expect

Re:Find is a beautiful tool by masklinn on Sunday July 24, 2011 @02:42PM (#2800009)
> Second does what I expect

Both do what you expect once you understand `-name` and `-delete` are predicates (not switches) and find short-cuts.

Re:Find is a beautiful tool by shabble on Sunday July 24, 2011 @07:03PM (#2800590)
The other big gotcha that took a while to sink in was

  find -name "foo*" -or -name "*bar" -print
which should actually be

  find \( -name "foo*" -or -name "*bar" \) -print
to do what you might expect (print things matching beginning with foo or ending with bar)

Without the parens, it gets interpreted as

  -name "foo*" -or ( -name "*bar" -and -print ), 
and hence only prints things that match the latter predicate.
Re:Find is a beautiful tool by parfe on Sunday July 24, 2011 @03:49PM (#2800180)
Yes, well I know that now that I lost the contents of a project directory. Live and learn.
Re:Find is a beautiful tool by shabble on Sunday July 24, 2011 @07:55PM (#2800699)
I'm suitably conditioned at this point to always give it a trial run with -print before using -delete, and -exec echo '{}' \; before any potentially dangerous commands.

Once bitten, etc...