Command Substitution using ``

I am new to stackexchange and to Linux also. Thanks in advance.

Welcome to both!

There are no backticks in your example, those are single quotes: '' Backticks looks like this: ``

Also, I would suggest that you simply don't use them (the backticks that is)! It is better to use this syntax for command substitution: $(<command>)

Read about why here.

Happy hacking!


The way I see it is that there's miscommunication: what bash manual authors call literal value isn't what we as regular users may understand as literal value. Also, there's two things at play. First, backquotes serve for command substitution, and second the "literal meaning of backslash". Lets start with the last one.

Quote from bash's manual, QUOTING section:

A  non-quoted backslash (\) is the escape character.
It preserves the literal value of the next character that
follows, with the exception of <newline>. 

What's not obvious here is that authors are talking about the actual backslash, the text. Single backslash itself stands for escape character, but what they're talking about in the link you provided is the double back slash. Take a look at this:

bash-4.3$ var=`echo \ `
bash-4.3$ echo $var

bash-4.3$ var=`echo \\ `
bash-4.3$ echo $var

bash-4.3$ var=`echo \\$ `
bash-4.3$ echo $var
$
bash-4.3$ var=`echo \\\ `
bash-4.3$ echo $var
\

It's difficult to wrap your head around this, but think of it this way: you have to escape the escape character first.

Tags:

Bash