7

In bash, I usually do grep -f <(command) ... (I pick grep just for example) to mimic a file input.

What is the equivalent in fish shell? I cannot find it in the documentation.

αғsнιη
  • 41,407
annahri
  • 2,075

1 Answers1

11

The <() and >() constructs are known as "process substitution". I don't use fish, but according to its documentation, it doesn't directly support this:

Subshells, command substitution and process substitution are strongly related. fish only supports command substitution, the others can be achieved either using a block or the psub shellscript function.

Indeed, psub seems to be what you want:

## bash
$ seq 10 | grep -f <(seq 4 5)
4
5

fish

~> seq 10 | grep -f (seq 4 5 | psub) 4 5

glenn jackman
  • 85,964
terdon
  • 242,166
  • 3
    fish currently has no equivalent to >() output process substitution. – glenn jackman Sep 09 '20 at 15:45
  • Also note that fish's psub uses a temporary file, so it's closer to zsh's =(...) form of process substitution than <(...). It has a psub --fifo, but is severely broken and cannot really be fixed (and still waits for the psub'ed command to finish for the (...) to expand which means it's still really not an IPC mechanism like ksh/bash/zsh's <(...)). – Stéphane Chazelas Sep 09 '20 at 16:01
  • 1
    Here, one can use command | grep -f - ... in any shell. – Stéphane Chazelas Sep 09 '20 at 16:02
  • 2
    Right, the value of process substitution is when you need to pass multiple streams of content to a process. E.g. diff -u <(sort file1) <(sort file2) – Colin D Bennett Dec 14 '20 at 23:24