
我以以下文件結構為例
c
-Git
-GitBranchTest
.acignore
[lots more files]
-subfolder
.acignore
[lots more files]
我正在嘗試複製所有 .acignore 檔案並將其重命名為 .gitignore,所以當我完成後,它應該看起來像這樣
c
-Git
-GitBranchTest
.acignore
.gitignore
[lots more files]
-subfolder
.acignore
.gitignore
[lots more files]
我嘗試過的以及我得到的錯誤:
我希望這已經夠清楚了。請幫忙。
答案1
這應該可以解決問題:
find ./ -name '.acignore' | sed 's/.acignore//g' | xargs -I {} cp {}.acignore {}.gitignore
如果您位於「c」目錄中,則為「./」。如果你在上面,那就是“./c”
答案2
我的嘗試有效,但非常冗長:)
for i in $(find /c/Git/GitBranchTest -name ".*" -print | grep acignore);do
from=$i
replacement=.gitignore
to=${from/.acignore/$replacement}
echo "cp $from $to" | sh
done