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


Click here to return to the 'Watch out for precedence of -o' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Watch out for precedence of -o
Authored by: sreeves on Feb 08, '03 04:36:36AM

find . -user foo -o -group bar -exec chown fiddle:faddle {} \\;

This doesn't change the ownership of files owned by user foo because the -o "or" operator has lower precedence than the implicit "and" between the -group and -exec, and evaluation stops once the left side of an "or" is known to be true.

You need to use parentheses to force the precedence (and they must be escaped from the shell), like this:

find . \\( -user foo -o -group bar \\) -exec chown fiddle:faddle {} \\;



[ Reply to This | # ]
More backslashitis
Authored by: sreeves on Feb 08, '03 04:39:57AM

Those should all be single backslashes.



[ Reply to This | # ]