On 19 November 2013 09:27, Joachim Backes <joachim.backes@xxxxxxxxxxxxxx> wrote: >> On 19 November 2013 02:05, Rick Stevens <ricks@xxxxxxxxxxxxxx> wrote: >>> On 11/18/2013 04:12 PM, Timothy Murphy issued this missive: >>> >>>>> edited /etc/password to change my old UID from 500 to 1000 >>>>> edited /etc/group to change my old GID from 500 to 1000 >>>>> chown -R tim:tim /home/tim/ >>>>> chown tim:tim /var/spool/mail/tim >>>> >>>> >>>> Just a note to say that I followed this advice, >>>> and it worked perfectly. >>>> Thank you. >>> >>> >>> In the future, you could also do: >>> >>> # find / -uid <your-old-UID> -gid <your-old-GID> -exec chown tim:tim >>> \{\} \; >>> >>> Example: >>> >>> # find / -uid 500 -gid 500 -exec chown tim:tim \{\} \; > > Alternative: # find / -uid 500 -gid 500 -| xargs chown tim:tim > > Advantage: Only 1 chown command invocation > Following up on my earlier email, I tried both the xargs and find -exec CMD '{}' '+' (N.B. difference between '+' and ';') strategies on a directory with 134858 files (both running echo) and found both actually ran 72 times. So they use similar strategies for combining arguments (there's a limit to how many arguments can be passed to a program, even without shell involvement). On the other hand, xargs chokes on a different input directory: ":xargs: unmatched single quote; by default quotes are special to xargs unless you use the -0 option" because xargs reads strings (via the pipe) it can be a bit trickier to get corner cases handled correctly, which is why I usually avoid it for working with general file names. find exec never needs to worry about quoting as it passes the arguments directly (though the program it's exec-ing needs to be able to handle general file names too). Find does have an option (action), -print0 which null terminates names to work with xargs -0 option: find / -uid 500 -gid 500 -print0 |xargs chown tim:tim However unless you want the extra options xargs allows (like interactive mode), I don't think this gains anything over '+' terminated exec. All this is contributes to why the chown -R --from is my preference for this case, there's no separate program invocation at all (and less issues about race conditions, or concerns about path). -- imalone http://ibmalone.blogspot.co.uk -- users mailing list users@xxxxxxxxxxxxxxxxxxxxxxx To unsubscribe or change subscription options: https://admin.fedoraproject.org/mailman/listinfo/users Fedora Code of Conduct: http://fedoraproject.org/code-of-conduct Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines Have a question? Ask away: http://ask.fedoraproject.org