On 11/14/15, Tim Shaw <tims...@mail.usa.com> wrote: > If I am using stdout redirection of a shell block to capture some text I am > generating, errors need to go to stderr, but it would also be good if they > went into the generated output. For example > for i in files*; do > if there_is_an_error; then > echo big long complicated error message goes here >&2 > echo big long complicated error message goes here > continue > fi > stuff_producing_text_on_stdout > done > file_i_am_creating > > I do not like duplicating code, such as the big long error message echo. So, > I could create a temp file or a temp shell var to save the message, but that > makes things more complicated than just duplicating the code, and also is > just not my style for something transient like this. > > What I would like to do is add a parameter to tee, "-2", that copies to > stderr in addition to stdout, just like "-" copies to stdout twice. So the > code becomes > echo big long complicated error message goes here | tee -2 > Simple, eh? > > Where's the tee source? I know this would not be POSIX compliant, but it > would work for me, and I hate having to rewrite everything from scratch for > trivial stuff like this.
tee /dev/stderr --- xoxo iza