Reputation: 4098
Is there a way to both echo the output of a command to the terminal and redirect to a file using a single file rather than using 2 separate commands in csh (for historical reasons i must use csh for this purpose). Currently I do this
echo "Hello World!"
echo "Hello World!" > textfile
echo "next line blah blah"
echo "next line blah blah" >> textfile
Upvotes: 4
Views: 3693
Reputation: 64308
This is exactly what tee
is for:
echo "Hello World!" | tee textfile
For multiple outputs, you can use
(
echo "Hello World!"
echo "next line blah blah"
) | tee textfile
or use the append option with tee
.
echo "Hello World!" | tee textfile
echo "next line blah blah" | tee -a textfile
Upvotes: 7