What is Bash Process Substitution? (Expansion)
About
On systems that can support it, there is an additional expansion available: process substitution
A list is run asynchronously, and its input or output appears as a filename (ie file path)
- If the >(list) form is used, writing to the file will provide input for list.
- If the <(list) form is used, the file passed as an argument should be read to obtain the output of list.
Example
Pass a list as filename/path argument <(list) form
It permits to pass a string as a file path.
Example: If the cli script expect only a path (ie a file descriptor), you can still give it generated content like that:
# diff between 2 inline file
diff -u <(printf "a\nb\nc\n") <(printf "a\n")
#
# generally
command <(echo "Content")
Example >(list) form
echo test | tee >(cat) >/dev/null
Note
When using process substitution, bash creates the file descriptor at /dev/fd/x such as /dev/fd/63
