A function mycommand
which runs command
and:
- Gives me three log-files which are:
- *.stdout.log: everything from
stdout
- *.stderr.log: everything from
stderr
- *.full.log: everything (i.e., both
stderr
andstdout
)
- *.stdout.log: everything from
- Prints all output to screen
The idea is that I can quickly see through the errors, skim for additional info in stdout
. But in some cases both (stdout
and stderr
) messages should be seen as one as it gives context, thus I want a third file to do that. For real-time overview I obviously want to see it on my screen too.
This works but it is rather clumsy and doesn't look nice. I'm unsure whether this is the right way to do it or I should improve the code.
The snippet is from my *.*shrc.
mycommand () { command "$@" \
> >(tee command_"$@"_$(date +%F_%T).stdout.log command_"$@"_$(date +%F_%T).full.log) \
2> >(tee command_"$@"_$(date +%F).stderr.log command_"$@"_$(date +%F_%T).full.log >&2 ) } \