Command substitution

On a keyboard, there is one interesting key, the backward quote, `. This key is normally situated below the Esc key. If we place text between two successive backquotes, then echo will execute those as commands instead of processing them as plain text.

Alternate syntax for $(command) is the backtick character `, which we can see as follows:

$(command) or `command`

For example:

  • We need to use proper double quotes, as follows:
$ echo "Hello, whoami"
  • The next command will print the text as it is; such as Hello, whoami:


Hello, whoami
  • Use proper double quotes and single backquotes:
$ echo "Hello, `whoami`."Hello, student
  • When we enclose whoami text in the ` characters, the same text that was printed as plain text will run as a command, and command output will be printed on the screen.
  • Use proper double quotes:
$ echo "Hello, $(whoami)."Hello, student.
  • This is the same as earlier.

Another example:

$ echo "Today is date"


Today is date

A similar example:


Another example is:

$ echo "Today is...

Related Articles

Calculating and reducing the runtime of a script

In this article, we are going to learn how to calculate and reduce the script’s runtime. A simple time command will help in calculating the execution time.PrerequisitesBesides having a terminal open, make sure you have the necessary scripts present in your...

read more

Lorem ipsum dolor sit amet consectetur


Submit a Comment

Your email address will not be published. Required fields are marked *

four × one =