Reputation: 117
I want to copy the content of source folder to destination folders in one line, is that possible ?
I have this
cp -r source/* dest1 dest2 dest3
but it doesn't work, what it does it copies the 3 folders (source dest1 dest2) in dest3 and I want the content from source folder to each dest folder.
Upvotes: 0
Views: 38
Reputation: 1935
Use a for
:
for dest in dest1 dest2 dest3; do cp -r source/* "$dest"; done
Upvotes: 0
Reputation: 242443
Do you mean you want to make three copies?
for dest in dest1 dest2 dest3 ; do
cp -r source/* "$dest"
done
Or, use xargs
to avoid the loop:
echo dest1 dest2 dest3 | xargs -n1 cp -r source/*
Upvotes: 1