How to redirect anything written on a file to another file in linux?

Suppose we have two files, a.txt and b.txt . If we write anything in a.txt & b.txt, it should be redirected to c.txt.

tee may help for this purpose.

tee: duplicate standard input

You may try a command like this:

echo "hello" | tee -a a.txt >>b.txt

Both a.txt and b.txt will contain the “hello”.


No , but it should be redirected to c.txt
The data of both a.txt and b.txt should be redirected to third text file.
As i am giving input to a & b , it should be redirected to c.txt simultaneaously.


The method above shows redirecting output a.txt -> b.txt.

Are what you need “a -> c and b -> c” or “a -> b -> c“.

Both case can be derived from the above command with the similar idea.

Eric Ma

Eric is a systems guy. Eric is interested in building high-performance and scalable distributed systems and related technologies. The views or opinions expressed here are solely Eric's own and do not necessarily represent those of any third parties.

Leave a Reply

Your email address will not be published. Required fields are marked *