如何创建一个 bash 脚本来遍历一些文件并执行一些涉及名称更改的操作:
在除 components/* 之外的所有子目录中查找所有 index.html 文件,并像这样处理每个文件:
mv dir1/index.html dir1/index_dev.html
vulcanize -o dir1/index.html dir1/index_dev.html
mv dir2/index.html dir2/index_dev.html
vulcanize -o dir2/index.html dir2/index_dev.html
...
谢谢
最佳答案
你可以拥有:
for FILE in */index.html; do
[[ $FILE == components/index.html ]] && continue ## Skip.
mv "$FILE" "${FILE%.html}"_dev.html
done
关于linux - Bash 脚本,用于循环遍历一些带有名称更改的文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24772159/