문제

Let's say I have text file called template.txt. template.txt contains the text "hello world."

I also have 10 other files named, message1, message2, message3, ect.

How can I copy the contents of template_message into message1, message2, message3, ect?

So far I've tried:

cp --copy-contentes template.txt *

cp --copy-contentes template.txt | xargs ls
도움이 되었습니까?

해결책

With a loop:

for file in message*
do
    cp template.txt "$file"
done

다른 팁

yet another way of doing this

ls message* | xargs -n1  cp template.txt

Use a for loop and append the index to the end of your destination file.

for i in {1..10};
do
    cp template.txt "message$i"
done
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top