linux - 在/template 文件夹中查找所有 *.tpl 文件并递归地对它们进行 666 修改

标签 linux permissions find chmod

我需要在/template 文件夹中找到所有 *.tpl 文件并递归地修改它们。顺便说一句,chmoding 文件递归地意味着什么?我猜它会找到所有 *.tpl 文件并将它们更改为 666。这将如何递归?

我有这个,但它不起作用:

find /template -type f \( -iname "*.tpl" \) | xargs chmod 666

有没有更好的方法来做这样的事情?

最佳答案

进一步偏离您对自己问题的回答:),您也可以在脚本中执行以下操作,尽管您的单行代码有效。我添加了一些代码,以便您也可以重新运行此脚本以查看不同的目录。

#!/bin/bash
if [[ $1 = "" ]] ; then
  echo "Please provide a directory to the script... For example: ./thisScript /directoryTosearch"
  exit 2
fi

for i in $(find $1 -type f -iname "*.tpl") ; do
  echo "Changing permissions on ${i}"
  chmod 666 ${i}
done

I 通过回显,以便您在屏幕上显示一个漂亮的输出,说明更改了哪些文件。

关于linux - 在/template 文件夹中查找所有 *.tpl 文件并递归地对它们进行 666 修改,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34684274/

相关文章:

linux - 使用 grep 如何搜索某些字符串并排除同一记录中的某些字符串

linux - JR 报告未在使用 Struts 2 的 Linux 上生成

linux - 在 R 中运行系统命令,然后将输出写入文件

linux - 从 shell 脚本中的变量运行命令

linux - 连接两个数字卡和 Asterisk 盒时出现 IRQ 问题

ios - 在 Swift 2.0 中检查权限

Java应用程序安全权限

php - Windows 2019 和 PHP 7.3 : "session_start(): ps_files_cleanup_dir: opendir failed: No such file or directory (2)"

macos - 在 Mac OSX 10.5 中,它找不到我的终端命令 sudo、find 等

javascript - 在 InDesign javascript 中使用变量更改文本