How to redirect output of multiple commands to one file?
bash, io-redirection
Solution
Note you can reduce the number of ssh calls:
{ ssh host tail -f /some/file |
tee >(awk ...) >(grep ...) >/dev/null
} > /some/file &
example:
{ echo foobar | tee >(sed 's/foo/FOO/') >(sed 's/bar/BAR/') > /dev/null; } > outputfile
cat outputfile
fooBAR
FOObar
Problem
I have a bash script that contains the following two commands: ``` ssh host tail -f /some/file | awk ..... > /some/file & ssh host tail -f /some/file | grep .... > /some/file & ``` How can I make the output of both commands be directed into the same file?