1835330 Members
2263 Online
110078 Solutions
New Discussion

.snapshot

 
navin
Super Advisor

.snapshot

Hello ,
I have to chown recursively a directory and need to leave just one directory underneath it called .snapshot.
Is it possible.Is the below command right?
Thanks Much

chown -R wic /project4 -prune .snapshot
Learning ...
5 REPLIES 5
slydmin
Advisor

Re: .snapshot

cd to project4 and run the following

find . -name '*' | egrep -w '.snapshot' | xargs chown -R wic -


hth,
-S
slydmin
Advisor

Re: .snapshot

Oops I must have made a mistake...

u had it right...your command should work

i have been of no help :)
Dennis Handly
Acclaimed Contributor

Re: .snapshot

>Is the below command right?

There is no -prune in chown, only in find(1).

>slydmin: find . -name '*' | egrep -w '.snapshot' | xargs chown -R wic -

This is close but you need some corrections:
find /project4 | fgrep -v .snapshot | xargs chown wic

You also might be able to use ! -name .snapshot and -prune with -exec.
And this will work if not too many files:
$ cd /project4
$ chown -R wic $( ls !(.snapshot) )

>you had it right. your command should work

I don't see how?
slydmin
Advisor

Re: .snapshot

Actually right after I replied, I tested the command on /tmp area. It seems to work with -prune.

My initial thought was, hey only find have --prune option, so I posted that xargs command, ofcourse that did not work as expected.

But "chown someuser * -prune .somedir"
actually works (after cding to the correct directory) on my system.



Dennis Handly
Acclaimed Contributor

Re: .snapshot

>I tested the command on /tmp area. It seems to work with -prune.

It doesn't work for me. -prune is just a file.
Basically I got errors because the chown were done twice for the name after -prune and I didn't own it the second time.

Besides doing the easy find | fgrep -v | xargs chown, you can work much harder:
$ find . \( ! -path "./.snapshot" -a ! -path "./.snapshot/*" \) | xargs chown ...