5

Say I want to send the output of to commands into another.

cat a.txt && ls

I can do this:

fish -c "cat a.txt && ls" | another_command

But it seems clunky, is there a way to do this without running a new instance?

2
  • You can redirect the output with arrow symbol (greater than and less than symbols).
    – Biswapriyo
    Commented Feb 13, 2019 at 6:34
  • @Biswapriyo, right - but how to do this for two commands to pipe into another_command?
    – ideasman42
    Commented Feb 13, 2019 at 8:02

1 Answer 1

6

use a begin...end block

begin; cat a.txt; ls; end | another_command

or with whitespace

begin
    cat a.txt
    ls
end | another_command
3
  • This appears to wait until the entire block executes until anything is sent down the pipe, which renders this feature near useless. Commented Apr 21, 2020 at 16:28
  • Can I ask that your log this finding at github.com/fish-shell/fish-shell/issues Commented Apr 21, 2020 at 17:14
  • I'm running fish 3.4.1 and it seems to output as soon as the first command outputs, at least using this test: begin ; echo hi ; sleep 2 ; echo bye ; end | cat Commented May 4, 2022 at 17:21

You must log in to answer this question.

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