Reputation: 2371
In tcsh
I want to redirect command line outputs to a file, but I still want to show them in the command line.
Did a little bit search that
./MyCommand.sh 2>&1 | tee /tmp/Output.txt
should do the job. But I got an error like:
Ambiguous output redirect
Upvotes: 1
Views: 661
Reputation: 64318
It isn't clear from the question if you want to redirect stdout only, or stdout and stderr.
Using |
will redirect stdout to tee
(which outputs it to a file and to terminal), leaving stderr untouched (so it only goes to terminal):
./MyCommand.sh | tee /tmp/Output.txt
Using |&
will "merge" stdout and stderr, and tee
will redirect both to file and to terminal:
./MyCommand.sh |& tee /tmp/Output.txt
Upvotes: 0
Reputation: 206607
Use of 2>&1
to combine stderr and stdout works only in bash
and sh
. It does not for csh
or tcsh
. A work around is suggested at Redirect stdout to stderr in tcsh.
Upvotes: 2
Reputation: 5467
In bash
instead of 2>&1
I use |&
Not sure how this plays out for tcsh
, but this question isn't currently tagged for it and hoping this helps someone else.
According to this redirect stderr to stdout in c shell you can't do this in csh
which tcsh
extends which could be related
Upvotes: 0