我有以下Mac命令可以将index.php
复制到/Library/WebServer/Documents
内的所有子目录中:
for i in /Library/WebServer/Documents/*
do
if [ -d "$i" ] # if it's a directory
then
sudo cp /Library/WebServer/Documents/index.php "$i"
fi
done
如何复制index.php
子文件夹的所有子文件夹(and their subfolders too
)内的/Library/WebServer/Documents
?
例如,
/Library/WebServer/Documents/folder1/folder2
,/Library/WebServer/Documents/folder1/folder2/folder3/
,...
答案 0 :(得分:1)
find /Library/WebServer/Documents/ -type d -exec cp /Library/WebServer/Documents/index.php {} \;
应该成功。您可能会收到有关/Library/WebServer/Documents/index.php
与自身相同的警告。忽略它,只是find
尝试将/Library/WebServer/Documents/index.php
复制到/Library/WebServer/Documents/index.php
而cp
发现它们是同一个文件。