Duplicate output of a program [duplicate]

Sometimes you want to have the output in a special file. So you can do something like this:

ls > test.txt

But sometimes I want to have the output also on my command line, for example when the program takes additional input and you want to see what the program wants you to input.

How this can be done?

Answer

You can do it with tee:

ls | tee test.txt

Attribution
Source : Link , Question Author : Henry Weinert , Answer Author : jesse_b

Leave a Comment