I found: "How do I escape backticks in a comment?", but I want to escape backticks, if I use backticks to format code in an answer.

The following doesn't work:

`sudo update-initramfs -v -u -k \`uname -r\``

The result is this:

sudo update-initramfs -v -u -k \uname -r``

Desired goal, but with using backticks:

sudo update-initramfs -v -u -k `uname -r`
share
up vote 7 down vote accepted

The following (without four spaces):

``sudo update-initramfs -v -u -k `uname -r` ``

generates the desired goal:

sudo update-initramfs -v -u -k `uname -r`

Source: How can the backtick character ` be included in code?

share

You can indent code by four spaces instead of using a backtick.

`hey everybody`

For more information:

share
2  
I know, I used it in my question. – BuZZ-dEE Jan 25 '13 at 12:09

Note: This answer is somewhat off topic as it doesn't directly answer the question; however I believe that it adds value/info so I'm posting.

Use of backticks e.g. `...` is the legacy (non-POSIX compliant) BASH method of command substitution. As a rule $(...) should be used instead. It's POSIX compliant and there are a ton of other good reasons! For most of them see: http://stackoverflow.com/questions/9449778/what-is-the-benefit-of-using-instead-of-backticks-in-shell-scripts

share

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .