I would like to write some filtered output of a given command (rsync
) into a file but keep the complete unfiltered output on stdout (the screen/terminal).
I've tried some combinations of sed
, tee
& process substitution
but cannot make this work.
Here's what I've got so far:
rsync -aAXz --stats -v src dest > >(sed '0,/^$/d' | tee -a "summary.log")
sed '0,/^$/d'
deletes everything before the first blank line which leaves rsync
's summary and deletes the leading verbose output. This is working as expected and only prints the summary to summary.log
.
Obviously it also deletes the verbose output from stdout
since the tee
command only receives the filtered sed
output over the pipe.
How can I write to stdout
before filtering with sed
to see all the verbose output on the screen/terminal?