Variables via external commands
Sometimes, while writing a script, you will have to run a certain command and then use its output to do something in your script. A complicated way to do that is by using redirection. We say complicated because once you have to use redirection, you are unable to use it for other things. You could redirect to different file descriptors, but that is going to complicate things even more.
Getting ready
You will soon notice that it is hard to separate different things related to shell commands and functions. The reason for this is that there are a few fundamental rules that then get repeated in a different way. We are going to mention some of them a few times through this book, not because we like redundancy but because you need to completely understand those rules to be able to write good scripts.
This is why shell expansion exists, and there are two ways to put it into action to accomplish our task.
How to do itβ¦
There are two...