在bash脚本中,我想用该给定文件夹的用户和组所有者递归锁定任意文件夹的所有子文件夹。
我的方法就像使用 stat -c "%U %G" .
但这只会返回一个模式 username[whitespace]groupname
当然,我可以尝试使用其他工具将空白替换为,:
但是如果有的话,我宁愿使用一种更为“内置”的方式,仅将当前所有权应用于子文件夹。
chown
,例如chmod
,可以使用参考:
chown [OPTION]... --reference=RFILE FILE...
Change the owner and/or group of each FILE to OWNER and/or GROUP. With
--reference, change the owner and group of each FILE to those of RFILE.
所以:
chown --reference=/some/folder -R /some/folder
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句