繁体   English   中英

Linux命令cp产生省略目录

[英]Linux command cp producing omitted directory

我想在网站的 100 个不同目录中放置 1 个名为“test1.html”的文件。

目录结构如下

\/home\/domain.com\/public_html\/ (每个目录的 domain.com 名称都会更改,所以我使用 * .

文件在这里:\/root\/test1.html

我已经通过root帐户尝试过: cp test1.html \/home\/*\/public_html\/<\/code>但是给我

cp: omitting directory `/home/domain1.com/public_html/'
cp: omitting directory `/home/domain2.com/public_html/'

尝试:

for dest in /home/*/public_html/
do 
   cp test1.html $dest
done

由于您是在用户拥有的目录中写入内容,因此请注意umask设置-它控制文件的权限。 您可以使用cp -p保留对test1.html的确切权限。

尝试这个:

cd /home/; find . -name public_html -type d | xargs -I {} cp /root/test1.html {};

应该写成: cp -R test1.html \/home\/*\/public_html\/<\/code>

-R 代表递归,没有它它不想做所有的目录。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM