Today, I learned about shell process substitution from Break on Penguin’s latest video.
Assume you have two files:
$ cat file1
a
b
c
$ cat file2
c
b
a
To see if they are identical when sorted without manually creating your own temporary files, you can:
diff <(sort file1) <(sort file2)
What is happening here?
<() is doing process substitution, which is running the command and then exposing its output as a temporary file.
Super neat!