Command substitution is basically another way to do a pipe, you can use pipes and command substitution interchangeably, it's up to you which one you find easier...
Command substitution can be done in two distinct ways.
-
- Method One (back-quotes)
-
Simply type:
command_1 `command_2 -options`
|
This will execute "command_2" and it's output will become the input to "command_1".
|
Backquote key |
|
The back-quote key is usually located at the same place as the tilde, above the [Tab] key.
|
- Method Two (dollars sign)
-
Simply type:
This will execute "command_2" and it's output will become the input to "command_1".
- Using the pipe instead
-
You can of course use pipes to do the same thing, if you don't know what a pipe is, please see Section 6.2. For example instead of doing:
less $cat file1.txt file2.txt
|
You could do:
cat file1.txt file2.txt | less
|
And end up with exactly the same result, it's up to you which way you find easier.