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?

1 Answers1

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
glenn jackman
  • 26,306
  • This appears to wait until the entire block executes until anything is sent down the pipe, which renders this feature near useless. – Anton Barkovsky Apr 21 '20 at 16:28
  • Can I ask that your log this finding at https://github.com/fish-shell/fish-shell/issues – glenn jackman Apr 21 '20 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

    – Charlie Groves May 04 '22 at 17:21