Process Substitution
Explore how to use the Bash process substitution operators <() and >() to streamline commands by substituting outputs as file inputs, reducing reliance on temporary files. This lesson helps you understand these operators in contrast to $(), enhancing your ability to write cleaner Bash scripts and commands.
We'll cover the following...
How Important is this Lesson?
I spent years reading and writing bash before I understood this concept, so this lesson can be skipped. However, since I learned about process substitution, I use it on the command line almost every day, so I recommend you learn it at some point.
Simple Process Substitution
Type this in to set files up for this lesson:
You’ve created two folders with slightly different contents.
Now let’s say that you want to diff the output of ls a and ls b (a trivial
but usefully simple example here). How would you do it?
Note: if you are not familiar with the
diffcommand, you can find an introduction to it here.
You might do it like this:
That works, and there’s nothing wrong with it, but typing ...