我想在文件夹上递归运行chown
,但是我不想包含名为"ssl.cert.webmintmp.26599"
或"ssl.cert.webmintmp.356849"
的文件,因此我需要在末尾用通配符替换数字。并且该文件之前的文件夹也应为通配符,因为存在多个不同的文件夹名称。
我尝试跑步:
sudo chown -R user:apache /home/ !({ssl.cert.**,**/ssl.cert.**})
根据我在这个问题上的发现,该方法不起作用; (How do I exclude a folder when performing file operations i.e. cp, mv, rm and chown etc. in Linux)
当我得到错误时;
./chowntest.sh: line 2: syntax error near unexpected token `('
./chowntest.sh: line 2: `sudo chown -R user:apache /home/ !({ssl.cert.**,**/ssl.cert.**})'
这可行吗?
chown -R
不会对传入的内容进行任何解释。使用!(...)
之类的内容的任何尝试均由外壳程序解释。如果要在递归中支持特殊逻辑,请使用find
:
find /home ! -name 'ssl.cert.*' -exec chown user:apache '{}' \;