LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Replacing ownership of certain files (https://www.linuxquestions.org/questions/linux-general-1/replacing-ownership-of-certain-files-785853/)

mocambo 01-30-2010 01:39 PM

Replacing ownership of certain files
 
Is there any working commandline alternative to

# find /some/dir -group xxx -user yyy | chown xxxxx:yyyyy

The main purpose is to replace ownership and goup of certain files in subdirectories. Or nevertheless I need to write shell script for that simple operation ?

stonehinge03 01-30-2010 01:47 PM

chown -R (for recursive) should work.

Hmmm. No that would change them all. You want to just change those owned by certain users and leave the rest alone, right?

ozanbaba 01-30-2010 01:50 PM

find /some/dir -group xxx -user yyy -exec chown xxxx:yyyy {}\;

mocambo 01-30-2010 05:20 PM

Quote:

Originally Posted by ozanbaba (Post 3846378)
find /some/dir -group xxx -user yyy -exec chown xxxx:yyyy {}\;

ozanbaba's solution did exactly what I'm looking for except there is extra space needed between {} and \;.

Thanks !

ozanbaba 01-31-2010 04:16 AM

Quote:

Originally Posted by mocambo (Post 3846589)
ozanbaba's solution did exactly what I'm looking for except there is extra space needed between {} and \;.

Thanks !

sorry about that

chrism01 01-31-2010 11:41 PM

http://linux.die.net/man/1/chown
Quote:

--from=CURRENT_OWNER:CURRENT_GROUP
change the owner and/or group of each file only if its current owner and/or group match those specified here. Either may be omitted, in which case a match is not required for the omitted attribute.


All times are GMT -5. The time now is 09:23 PM.