Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to put text in multiple files using command ECHO? [duplicate]

How to put text in multiple files using command echo?

I want to put same text in multiple files, but this command works on only one file:

echo "my text" > myfile.php

But I want a working command line for something like this:

echo "my text" > myfile.php,myfile.txt,myfile,myfile.html

How can I put text in multiple files or custom extension files?

like image 986
bigsmoke Avatar asked Mar 19 '26 01:03

bigsmoke


2 Answers

The tee command copies what it reads from standard input to one or more files, and also writes the data to its standard output. So you can use:

echo my text | tee file1 file2 file3 > /dev/null

or maybe:

echo my text | tee file1 file2 > file3
like image 114
Shawn Avatar answered Mar 21 '26 17:03

Shawn


echo your text | tee -a f1 f2 f3

-a for Append to the given FILEs. Do not overwrite. -I for Ignore interrupt signals.

like image 42
A.Khan Avatar answered Mar 21 '26 15:03

A.Khan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!