1

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?

Mike
  • 175
  • 1
  • 10

2 Answers2

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?"

Mike
  • 175
  • 1
  • 10
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