Command substitution in BASH


BASH has the ability to execute a command string and replace that string with the output of the command. Or to say it another way, the output of a command will replace the command itself.

There are 2 ways to accomplish this.

The first is to surround the command with backticks or blockquotes.

You can also substitute with dollar symbol and parenthesis.

The following will do a direct substitution of the current username on the command line.

Another great use is the ability to assign a command to an environment variable.

or using the other format