|
|
|
Command substitution lets you capture the output of a command and use it as a value. This is one of the most powerful features in shell scripting. |
|
|
The modern syntax uses |
|
|
You can also use backticks, but |
|
|
Command substitution is commonly used to store command output in variables. |
|
|
You can use it directly in strings. |
|
|
Command substitution can be nested with |
|
|
Capture the contents of a file. |
|
|
Use it for conditional checks. |
|
|
Command substitution strips trailing newlines from the output. This is usually what you want. |
|
|
Store command exit in a variable too if needed. |
|
|
You can use command substitution in arithmetic. |
|