Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I've copied a folder of data from one linux server to another via a tarball.

The group ids (GIDs) don't match up on the two servers, so I now have files that look like

-rw-rw-r--   1 tim  1013   88 2008-11-14 10:18 config

There is a mixture of group ownerships in the folder, and I want to keep them owned by different groups on the same server, so I can't just use chgrp -R.

How do I change all files/folders with GID 1013 to another group, without affecting other files/folders?

Thanks

share|improve this question
    
Slightly off topic but... If you are transferring the files via NFS or Samba there are ways to map the ID's between machines, but they must be set up before the transfer begins. –  Chris Nava Apr 27 '10 at 14:53

2 Answers 2

up vote 5 down vote accepted
sudo bash -c 'find . -gid 1013 -print0 | xargs -0 chown :1212'

This would change them all files owned by group 1013 to gid 1212. You could add additional options like -type d to find to restrict it to something like only directories, see man find.

share|improve this answer
    
ta, i always forget about the -0 thing. –  Tim Abell Apr 27 '10 at 14:40
find . -gid 1013 | xargs chgrp newgroup
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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