Questions tagged [backticks]

For questions relating to the backtick character (`), also known as the backquote, which has various special meanings in computing.

A backtick or backquote or grave accent is the character,

       `

On British and American QWERTY keyboards, this is located in the upper left corner, next to the 1 key. It is notoriously difficult to type on some European keyboards, requiring up to four keystrokes.

Backticks were introduced by Unix shells to run a sub-shell. The concept has been adopted by other languages and tools such Perl, PHP, Ruby, and Make. The newer alternative syntax $(<command>) in POSIX-compliant shells is more flexible as it allows nesting.

In Python 2, backticks enclose an expression to be evaluated and converted to its string representation. This feature was removed in Python 3, as it was deemed not sufficiently beneficial to warrant the syntax. The same effect can be accomplished with repr() instead.

In Markdown, backticks are used as a shorthand for emitting <code></code> tags in HTML.

In TeX typesetting, a backtick renders as an opening curly quote (‘).

In the programming languages D and Go, backticks surround string literals.

Further uses of backticks in computing can be found in the Wikipedia article on the grave accent.

311 questions
436
votes
11 answers

Usage of the backtick character (`) in JavaScript

In JavaScript, a backtick† seems to work the same as a single quote. For instance, I can use a backtick to define a string like this: var s = `abc`; Is there a way in which the behavior of the backtick actually differs from that of a single…
vancewang
  • 5,120
  • 3
  • 15
  • 14
248
votes
9 answers

What is the benefit of using $() instead of backticks in shell scripts?

There are two ways to capture the output of command line in bash: Legacy Bourne shell backticks ``: var=`command` $() syntax (which as far as I know is Bash specific, or at least not supported by non-POSIX old shells like original…
DVK
  • 126,886
  • 32
  • 213
  • 327
181
votes
11 answers

Using backticks around field names

After reading a couple of answers and comments on some SQL questions here, and also hearing that a friend of mine works at a place which has a policy which bans them, I'm wondering if there's anything wrong with using backticks around field names in…
nickf
  • 537,072
  • 198
  • 649
  • 721
117
votes
5 answers

Batch equivalent of Bash backticks

When working with Bash, I can put the output of one command into another command like so: my_command `echo Test` would be the same thing as my_command Test (Obviously, this is just a non-practical example.) I'm just wondering if you can do the…
MiffTheFox
  • 21,302
  • 14
  • 69
  • 94
91
votes
6 answers

Why does this Kotlin method have enclosing backticks?

What are the backticks used for in the snippet below? Why add them around the fun is(amount:Int ):Boolean { ... }? verifier.`is`(amount)
LF00
  • 27,015
  • 29
  • 156
  • 295
89
votes
11 answers

Equivalent of Bash Backticks in Python

What is the equivalent of the backticks found in Ruby and Perl in Python? That is, in Ruby I can do this: foo = `cat /tmp/baz` What does the equivalent statement look like in Python? I've tried os.system("cat /tmp/baz") but that puts the result to…
Chris Bunch
  • 87,773
  • 37
  • 126
  • 127
73
votes
4 answers

How does one escape backticks in markdown?

I am writing some documentation in markdown and I want to document how to create a text file using a bash HEREDOC. Here is the command I want to document: # cat > /tmp/answers.txt < value1=blah > value2=something else > value3=`hostname` >…
Red Cricket
  • 9,762
  • 21
  • 81
  • 166
63
votes
1 answer

What is the difference between backticks and $() in a Bash script?

I see two different forms in Bash scripts which seem to do the same: `some command` and $(some command) What is the difference between the two, and when should I use each one of them?
Misha Moroshko
  • 166,356
  • 226
  • 505
  • 746
49
votes
3 answers

Escape backquote in a double-quoted string in shell

For the command: /usr/bin/sh -c "ls 1`" (a backquote after 1). How to make it run successfully? Adding a backslash before "`" does not work. ` is a special char as we know, and I tried surrounding it with single quote too (/usr/bin/sh -c "ls…
user221839
46
votes
2 answers

Clojure - difference between ' (apostrophe) and ` (backtick)

I'm fairly new to Clojure and I'm not sure I completely understand the difference between apostrophe and backtick in Clojure. (def x 5) ;; Question 1 (+ x x) ;; evaluates to 10 '(+ x x) ;; evaluates to (+ x x) `(+ x x) ;; evaluates to…
wmock
  • 5,382
  • 4
  • 40
  • 62
43
votes
3 answers

Back-tick vs single quote in js

Working on node.js (server side), I wonder if I should use all back-ticks (`) instead of the regular quotes (" or ') all the time since it will make the code consistent. Is there any specific reason for keeping different type of quotes for different…
Ulysses
  • 5,616
  • 7
  • 48
  • 84
41
votes
5 answers

Is it possible to have a comment inside a es6 Template-String?

Let's say we have a multiline es6 Template-String to describe e.g. some URL params for a request: const fields = ` id, message, created_time, permalink_url, type `; Is there any way to have comments inside that backtick…
lukash
  • 668
  • 1
  • 5
  • 10
33
votes
3 answers

What do backticks do in R?

I'm trying to understand what backticks do in R. From what I can tell, this is not explained in the ?Quotes documentation page for R. For example, at the R console: "[[" # [1] "[[" `[[` # .Primitive("[[") It seem to be returning the equivalent…
Megatron
  • 15,909
  • 12
  • 89
  • 97
29
votes
4 answers

What's the differences between system and backticks and pipes in Perl?

Perl supports three ways (that I know of) of running external programs: system: system PROGRAM LIST as in: system "abc"; backticks as in: `abc`; running it through a pipe as in: open ABC, "abc|"; What are the differences between them? Here's…
Nathan Fellman
  • 122,701
  • 101
  • 260
  • 319
24
votes
4 answers

Ruby Backticks - break command into multiple lines?

In Ruby, I know I can execute a shell command with backticks like so: `ls -l | grep drw-` However, I'm working on a script which calls for a few fairly long shell commands, and for readability's sake I'd like to be able to break it out onto…
asfallows
  • 5,998
  • 6
  • 29
  • 48
1
2 3
20 21