1

I am using the fish shell and try to log stdout and stderr into two separate files and printing them in the terminal at the same time (e.g., by piping each stream to tee).

In bash I would do (see https://stackoverflow.com/a/692407/5082444):

command > >(tee -a stdout.log) 2> >(tee -a stderr.log >&2)

How can I achieve the same in the fish shell?

3

You can do something similar with

begin; command | tee -a stdout.log ; end ^| tee -a stderr.log >&2

with the proviso that if the first tee writes anything to stderr, it will also get logged, which is not the case with the bash version.

| improve this answer | |
  • Does this permit interaction? I have a process that prints prompts and expects a response. – Aleksandr Dubinsky Feb 18 at 4:50
  • You may have problems, because output from the process might get buffered and you wont see the prompt until after you have typed the response. For example, create a file abc then use as command rm -i abc and you will not see the message rm: remove regular empty file 'abc'? until too late. – meuh Feb 18 at 9:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.