Dan
Dan

Reputation: 951

Find where owner OR group does not equal

I'm curious if these can be combined into a one-liner:

find /var/www/public_html ! -user _www -print0 | xargs -0 chown _www:_www > /dev/null 2>&1

and

find /var/www/public_html ! -group _www -print0 | xargs -0 chown _www:_www > /dev/null 2>&1

Can find look for files and folders not owned by _www in a one-liner? It's not clear to me from the man page if this is possible...

Upvotes: 2

Views: 1774

Answers (1)

John1024
John1024

Reputation: 113814

Just combine the two conditions together with a logical-or:

find /var/www/public_html \( ! -user _www -o ! -group _www \) -print0 | xargs -0 chown _www:_www > /dev/null 2>&1

Upvotes: 3

Related Questions