Append same text to many files using cat or echo?

26,004

Use tee to read from standard input and write to standard output and files.

echo "hello" | tee -a file1 file2

-a is the short (and portable/standard) for GNU tee's --append

Share:
26,004

Related videos on Youtube

neo0
Author by

neo0

Updated on September 18, 2022

Comments

  • neo0
    neo0 almost 2 years

    How can I write the same content to many text files by using cat or echo in only one command?

    For example I want to write "hello" to file1 and file2. I tried:

    echo "hello" >> file1 file2
    

    but it didn't work. How can I do it?

  • Brian Bruman
    Brian Bruman over 7 years
    Thanks, can flip it around for heredoc: tee -a aaa bbb ccc << EOF contents ... EOF.