I'd like to concatenate the output from echo with content of a file. I've tried the following comand:
echo "abc" | cat 1.txt > 2.txt
but the 2.txt
file only contains the content from 1.txt
. Why doesn't it work?
catconcatenationecholinux
I'd like to concatenate the output from echo with content of a file. I've tried the following comand:
echo "abc" | cat 1.txt > 2.txt
but the 2.txt
file only contains the content from 1.txt
. Why doesn't it work?
Best Answer
It does not work because the
cat
program in your pipe sequence was not instructed to read theecho
program's output from standard input.You can use
-
as a pseudo file name to indicate standard input tocat
. Fromman cat
on an msys2 installation:So try
instead.