chgrp files from one specific group to another

Discussion in 'Command Line' started by rgirardin, Mar 20, 2013.

  1. rgirardin

    rgirardin New Member

    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    Hi All,

    I was wonder if there was a way (without scripting) to change a set of files from one group to another only if the files belong to a certain group. My use case is I have a deep folder structure with some files owned by group A and some by group B. I want to do a chgrp on the top level folder but only have files owed by group a change to group C.

    i.e. chgrp -R groupA=>groupC folder

    I checked the man pages (didn't understand the bit about --reference if that is the way) and google with know luck. If I need to script I can, was just wondering if there's already some exitsting way.


    TIA
  2. glenn4uk

    glenn4uk New Member

    Messages:
    13
    Likes Received:
    1
    Trophy Points:
    3
    rgirardin,

    Sorry I don't quite undertand exactly what you're trying to do but I think what you want to look at is the find command with the -group option:

    find . -group A -exec chgrp C {} \;

    This might be what you're looking for. It locates all files in the current directory owned by group A and changes them to group C.
  3. rgirardin

    rgirardin New Member

    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    That was exactly what I needed.
    Thanks a lot!

Share This Page