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?

1 Answer 1


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.

  • Does this permit interaction? I have a process that prints prompts and expects a response. Commented Feb 18, 2020 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
    Commented Feb 18, 2020 at 9:29

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .