Pregunta

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?

¿Fue útil?

Solución

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.

Otros consejos

An example with expr:

xargs expr << HEREDOC | tee output.log
10 + 11
HEREDOC
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top