带大括号的 diff 表示什么?

带大括号的 diff 表示什么?
for i in $(find template -type f | sed 's/^template//') ; do
    diff -wBNu {,./template}$i

我可以理解 for 循环,它将遍历目录中的所有文件template,然后将所有以 template 开头的句子替换为''.这种理解正确吗?在这里做什么diff

答案1

大括号执行 shell 的“大括号扩展”。构造 {,./template}$i 生成一对单词,都包含 $i 的值,但后者前面有 ./template 。尝试命令

echo foo{,bar}

在 shell 提示符下查看它的运行情况。这在 bash 手册中的“大括号扩展”下有记录。

相关内容