We are using AWS S3 Buckets, and when you attempt to do a recursive chgrp
, it churns on the S3 bucket (essentially) indefinitely. Is it possible to execute chgrp
while excluding a directory?
Asked
Active
Viewed 1,235 times
1

Mike
- 175
- 1
- 10
2 Answers
2
The answer is the use of bash extglob
, and works here, as well as many other Linux functions that accept file designation in the /directory/*
form.
Changing the group of files greedily in a directory, while excluding a directory, is possible by first turning extglob
on, and then including the directory name to exclude as such:
shopt -s extglob
chgrp /directory/!(exclude)
And when you are done, turn the option off with the -u
flag.
shopt -u extglob
For a helpful Stack post on it, look at "How can I use inverse or negative wildcards when pattern matching in a unix/linux shell?"
1
You can use GNU find
's ability to not follow a directory path into another filesystem:
find /some/path -mount -exec chgrp groupname {} +

jordanm
- 889
- 5
- 9
-
Does this execute recursively? – Mike Apr 25 '15 at 12:43
-
@Mike yes, it is recursive. – jordanm Apr 25 '15 at 14:41