I want to run chown
recursively on a folder, but I don't want to include files named "ssl.cert.webmintmp.26599"
or "ssl.cert.webmintmp.356849"
, so I need to replace the number at the end by a wildcard character. And also the folder before that file should be a wildcard since there are several different folder names.
I've tried running:
sudo chown -R user:apache /home/ !({ssl.cert.**,**/ssl.cert.**})
By what I found on this question which didn't work; (How do I exclude a folder when performing file operations i.e. cp, mv, rm and chown etc. in Linux)
As I get errors;
./chowntest.sh: line 2: syntax error near unexpected token `('
./chowntest.sh: line 2: `sudo chown -R user:apache /home/ !({ssl.cert.**,**/ssl.cert.**})'
Is this doable?
chown -R
does not perform any interpretation of what you pass in. Any attempts to use things like !(...)
are interpreted by the shell. If you want to support fancy logic in your recursion, use something like find
:
find /home ! -name 'ssl.cert.*' -exec chown user:apache '{}' \;