GNU/Linux Command-Line Tools Summary
Prev
Chapter 6. Directing Input/Output
Next
6.3. Command Substitution
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)
- Method Two (dollars sign)
- Using the pipe instead
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.
Simply type:
command_1 $(command_2)
This will execute “command_2” and it's output will become the input to “command_1”.
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.
Prev
Home
Next
Usage
Up
Performing more than one command
* License

