Skip to Content
Learning Linux Shell Scripting
book

Learning Linux Shell Scripting

by Ganesh Sanjiv Naik
December 2015
Beginner
306 pages
5h 2m
English
Packt Publishing
Content preview from Learning Linux Shell Scripting

Command substitution

In the keyboard, there is one interesting key, the backward quote such as "`". This key is normally situated below the Esc key. If we place text between two successive back quotes, then echo will execute those as commands instead of processing them as plane 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 quoted inverted commas, as follows:
    $ echo "Hello, whoami"
    
  • The next command will print the text as it is; such as Hello, whoami:
    Hello, whoami
    
  • Use proper double inverted commas:
    $ echo "Hello, `whoami`."
    Hello, student
    

    When we enclose whoami text in the "`" character, the same text which was printed as plain text ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Learning Linux Shell Scripting - Second Edition

Learning Linux Shell Scripting - Second Edition

Ganesh Sanjiv Naik

Publisher Resources

ISBN: 9781785286216