Copy content of a file into multiple files
Hello everyone,
I am trying to copy the content of a text file into multiple files in a single command. Is there any way to achieve this? For example, A.txt contains: This is a simple text file. And I want to copy this content into some other files, named B.txt, C.txt ... so on. Thansk for your help! |
Simplest solution is to do it with a loop.
The cp command doesn't support multiple destinations. |
Code:
cat A.txt | tee B.txt C.txt D.txt >/dev/null |
Alright, we can achive this using following simple script:
#!/bin/sh for i in `cat fileslist.txt` do more [file] > $i done For users information, [file] is the file whose conetent you want to copy in all other files. And secondly, put a list of all files, in which you want to copy ccontent of the [file] file, into fileslist.txt file. |
Quote:
|
Quote:
|
or another way:
Code:
for i in {B,C,D}; do cp A.txt "$i".txt; done |
All times are GMT -5. The time now is 11:50 AM. |