2

In bash, you can pipe the same output to two commands using {}, i.e. in the following:

cmd0 | { cmd1 ; cmd2 ;} | cmd3

cmd1 and cmd2 get the output of cmd0 in their stdin, and cmd3 gets the output of cmd2 appended to output of cmd2 in its stdin.

What's the name of this {} feature and is there an equivalent in fish?

2
  • What exactly does "fish" stand for? Could you please provide a link to make it unambiguous? Did you take into account wether and why you really need to script this in "fish"?
    – Nepumuk
    Feb 6, 2020 at 18:49
  • 2
    @Nepumuk did you check the tags? Feb 6, 2020 at 19:11

1 Answer 1

2

The feature is called command grouping.

In the fish shell, it appears to be provided by using begin and end in place of bash's { and } braces - a feature I only discovered from a bug report:

Note that regardless of shell, the first command that is able to do so will consume standard input ex.

(bash):

$ echo foo | { sed 's/oo/aa/'; sed 's/oo/um/'; }
faa

(fish):

> echo foo | begin sed 's/oo/aa/'; sed 's/oo/um/'; end
faa

but

> echo foo | begin echo cmd1 ; sed 's/oo/um/'; end
cmd1
fum

You must log in to answer this question.

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