1

If the uid or gid of a file is 4294967295, I need to modify its permissions with chown. This will be a bandaid solution for an rsync issue in cygwin (Details here).

How can this be implemented?

5
  • BTW, next time you're tempted to use ls -R in a situation like this, read through mywiki.wooledge.org/ParsingLs. Dec 8, 2015 at 23:12
  • WOW-WOW thanks, I will try the find that 'that other guy' suggests
    – KiloOne
    Dec 8, 2015 at 23:15
  • Great edit, thanks Charles, I am learning :)
    – KiloOne
    Dec 8, 2015 at 23:17
  • It's a tricky balance -- trimming down this far risks folks being unhappy that you didn't show that you at least tried something yourself. On the other hand, hiding the details of what you're actually trying to accomplish in the weeds of an attempted implementation isn't helpful either. If I were doing this again, I might make the second paragraph more like: "My most recent attempt is filtering ls -R output through awk, but this approach is being difficult; is there a better approach?" -- which shows that you've actually put in some effort yourself. Dec 8, 2015 at 23:21
  • Agreed, will do better!
    – KiloOne
    Dec 8, 2015 at 23:24

1 Answer 1

1

XY indeed. Just use find:

find yourdir \( -uid 4294967295 -o -gid 4294967295 \)  \
    -exec chown youruser:yourgroup {} +
5
  • Wow, I've dabbled in too many languages and I am master of none :) Looks good I will give it a try :) shame shame on me!
    – KiloOne
    Dec 8, 2015 at 23:11
  • I am a little concerned about the -o which means 'expr1 -o expr2 Or; expr2 is not evaluated if expr1 is true' and the fact that whenever there is a bad value of either u or g, the chown changes both u and g. I believe that there are situations that g is bad but u is good and your code would seem to change the good u to youruser anyway.
    – KiloOne
    Dec 8, 2015 at 23:35
  • You can just as easily do find yourdir -uid 4294967295 -exec chown youruser: {} + -o -gid 4294967295 -exec chown :yourgroup {} +. I didn't study your rsync issue and the question didn't clarify. Dec 9, 2015 at 0:35
  • I have been trying that to see how much slower it is. In any case this appears to be the answer, thanks.
    – KiloOne
    Dec 9, 2015 at 1:01
  • It may not have been XY if what I should have asked is this [stackoverflow.com/questions/34205248/…
    – KiloOne
    Dec 11, 2015 at 14:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.