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:
If you want to copy the file test.txt in every directory in /tmp/target/ ...
create a test environment:
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 .
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
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
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.
Would you like to answer one of these unanswered questions instead?