I have tried to copy a file
test.txt to multiple directories with one command:
cp ~/test.txt ~/folder1 ~/folder2
But I didn't succeed. Is there a way to do that in one command so I can copy a file or even a folder to multiple directories?
The only bash command that I know which can copy/save to multiple destinations is
You can use it in your case as follows:
Another way to achieve a copy to multiple locations is the following command :
If dir1 or dir2 have sub-directories that you don't want the file copied into, add
Note that this will overwrite every file in
tries to copy two files (
If you want to make multiple copies of the file
(...and be careful if you have spaces embedded in the file names, you'll need quoting).
To copy whole directories you have to use the
this will create
You can create a help script , or you can do it with
This will make each directory as an argument to the
After a long search this work like a Charm also !
This will copy file.txt to every directory in your current location in terminal.
This will copy a folder to every sub directory in your current location in terminal.
I share it hope it helps others too .
If you want to copy the file test.txt in every directory in /tmp/target/ ...
create a test environment:
Thank you for your interest in this question.
Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).
Would you like to answer one of these unanswered questions instead?