Process Substitution
In this lesson, you will learn about process substitution, a handy way to save time and make scripts more concise and elegant. What you’ll learn will also allow you to capture the output of a command into a variable so that you can use it in other contexts or access it later.
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 ...