user2986500
user2986500

Reputation: 53

Linux command cp producing omitted directory

I want to place 1 file called "test1.html" in 100 different directories of website.

Directory structure is like the following

/home/domain.com/public_html/ (domain.com name are change for every directory so i use * .

File are here: /root/test1.html

I have try it by : cp test1.html /home/*/public_html/ via root account but give me

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

and so on.

how to place the one file in all domains directory?

it's Centos 5.9

Upvotes: 4

Views: 30424

Answers (3)

It should be written: cp -R test1.html /home/*/public_html/

-R stands for recursive and without it it doesn't want to do all the directories.

Upvotes: -1

Harry
Harry

Reputation: 1472

Try this:

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

Upvotes: 0

jim mcnamara
jim mcnamara

Reputation: 16379

Try:

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

Since you are writing in user-owned directories be careful of you umask setting - it controls permissions on the file. You can use cp -p to keep the exact permissions on test1.html preserved.

Upvotes: 3

Related Questions