我需要把文件在每个目录和子目录
我在Mac上使用Bash和Brew
我试过这个
for dir in \`//Users/oscarristolfi/Downloads/roma/\* . -type d\` ; do cp index.html ; done
我试过了,但它只显示回声,结果
/Users/oscarristolfi/Downloads/roma/copia.sh: line 7: //Users/oscarristolfi/Downloads/roma/cerco-amici: is a directory
我尝试添加一个目录变量,但什么也没有
for dir in \`//Users/oscarristolfi/Downloads/roma/\* . -type d\` ; do cp index.html $dir/index.html ; done
1条答案
按热度按时间h9a6wy2h1#
我会使用
find
而不是for
。假设index.html
存在于运行find
的当前目录中:向
cp
添加选项:-f
,如果您想强制覆盖目标目录中现有的index.html
。-n
,如果不想覆盖目标目录中现有的index.html
。我不熟悉MacOS和路径的
//Users
部分,但我假设它是指向主目录顶部的某种链接。