Question

Quite often I'll use the following construct to pipe output to a log file, keeping the output also on the display

./command 2>&1 | tee output.log

I'm trying to do something similar, but with using a here document:

./command << HEREDOC
params
HEREDOC 2>&1 | tee output.log

This doesn't work - is it possible to achieve this?

Was it helpful?

Solution

Sure.

./command <<HEREDOC 2>&1 | tee output.log
params
HEREDOC

The here-document doesn't begin until the next line. The rest of the command is parsed as normal.

OTHER TIPS

An example with expr:

xargs expr << HEREDOC | tee output.log
10 + 11
HEREDOC
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top