4

To put it lean and mean, how to duplicate something like:

echo 'hello'

to STDOUT and a file?

Like:

echo 'hello' 1>&0 | echo ... # and then?

1 Answer 1

11

Look up the tee program.

man tee:

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

Also, you can chain this program if you need multiple files, etc.

> echo "hello" | tee /tmp/h1.txt
hello
> cat /tmp/h1.txt
hello

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .