4

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`

3 Answers 3

7

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?

2

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

`hey everybody`

For more information:

1
  • 2
    I know, I used it in my question.
    – BuZZ-dEE
    Commented Jan 25, 2013 at 12:09
-1

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: https://stackoverflow.com/questions/9449778/what-is-the-benefit-of-using-instead-of-backticks-in-shell-scripts

You must log in to answer this question.

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