How to redirect anything written on a file to another file in linux?
Posted on In QASuppose 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.
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.