
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 手冊中的“大括號擴展”下有記錄。