1755854 Members
3126 Online
108838 Solutions
New Discussion юеВ

chown -R

 
Madhu Sudhan_1
Respected Contributor

chown -R

Hello
I use netapps, when I choose to change permissions using chown -R considers .snapshot directories which are part of the current filesystems for obvious reasons. How do I ignore .snapshot directories in this case.

Currently Iam using chown -R username:dba `echo *`.

Just looking if any better ways are in there.

Thank you,
Madhu
Think Positive
2 REPLIES 2
Elmar P. Kolkman
Honored Contributor

Re: chown -R

It depends on the location where you start the chown and the location of the mount of the netapp directory...
If you are at the place where the mount has taken place the 'chown -R username:dba *' (using the echo can only break things when there are spaces in filenames. leaving the echo out works just as fine) works, because filenames beginning with a dot are ignored.

If you are on a different level, it becomes harder. I think the best way would be using a find, filter out the .snapshot paths, and then do a chown on the single files. This can be done like this:
find . | grep -v '[.]snapshot' | while read file
do
chown username:dba $file
done

This will take a long time, though, because the chown is called not once but many times. I think it can be done more efficiently in perl. But this solution is simple and will work.
Every problem has at least one solution. Only some solutions are harder to find.
G. Vrijhoeven
Honored Contributor

Re: chown -R

Hi,

in one line

find . ! -path './.snapshot*' -xargs -exec chown {} \;

Gideon