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
23
votes
9 answers

Weird backticks behaviour in Active Record in CodeIgniter 2.0.3

Previously my all queries were running fine in CI version 2.0 but when I upgraded to 2.0.3 some of my SELECT queries were broken. CI is adding backticks (``) automatically, but in older version its running as it is. CI user manual have instructed to…
Jatin Dhoot
  • 4,294
  • 9
  • 39
  • 59
21
votes
4 answers

Why does IntelliJ keep removing backticks from this JavaScript template string?

I want to put "backticks" around my template strings. IntelliJ keeps removing them every time I try the wrap them around the string. Anyone's got a clue why its happening and how to solve this? I added a little code snippet of my .vue file where the…
Lucca
  • 1,447
  • 4
  • 16
  • 20
20
votes
2 answers

Display output of a Bash command and keeping the output in a variable

I'm not sure if it is possible but what I want to do is to run a bash command and storing the output in a variable AND display it as if I launched the command normally. Here is my code: VAR=`svn checkout $URL` So I want to store the output in VAR…
Selmak
  • 205
  • 1
  • 2
  • 4
19
votes
3 answers

PS1 command substitution fails when containing newlines on msys bash

This command succeeds $ PS1='$(date +%s) $ ' 1391380852 $ However if I add a newline it fails $ PS1='$(date +%s)\n$ ' bash: command substitution: line 1: syntax error near unexpected token `)' bash: command substitution: line 1: `date +%s)' If I…
Zombo
  • 1
  • 62
  • 391
  • 407
18
votes
2 answers

Practical application of backticks in Swift

From this document: To use a reserved word as an identifier, put a backtick (`) before and after it. I'm curious about the practical application of this. When would you actually want to name something `class`, `self`, etc.? Or, relatedly, why did…
Luke
  • 7,110
  • 6
  • 45
  • 74
18
votes
3 answers

How to render triple backticks as inline code block in Markdown?

I am writing a tutorial on GitHub about Markdown using Markdown and I want to write ``` but rendered as inline code block like this.
Protonotarios
  • 553
  • 4
  • 15
18
votes
3 answers

How do I use a perl variable name properly within backticks?

I need to execute the following code on a bash shell: mogrify -resize 800x600 *JPG Since the width and height are variables, I tried this: `mogrify -resize $widx$hit *JPG` However in compilation, I get the error that Global symbol "$widx" requires…
Joel G Mathew
  • 7,561
  • 15
  • 54
  • 86
17
votes
3 answers

Use backticks (`) or double quotes (") with Python and SQLite

I saw a similar question on Stack Overflow pertaining to Android, but I was wondering whether I should use backticks (`) or double quotes (") - using Python - to select table names or rowid or what have you. I tried single quotes - like this select…
dylnmc
  • 3,810
  • 4
  • 26
  • 42
16
votes
7 answers

How can I read the error output of external commands in Perl?

As part of a larger Perl program, I am checking the outputs of diff commands of input files in a folder against reference files, where a blank output (a match) is a passing result, and any output from diff is a fail result. The issue is, if the…
alexwood
  • 612
  • 2
  • 7
  • 14
13
votes
2 answers

Exactly how do backslashes work within backticks?

From the Bash FAQ: Backslashes (\) inside backticks are handled in a non-obvious manner: $ echo "`echo \\a`" "$(echo \\a)" a \a $ echo "`echo \\\\a`" "$(echo \\\\a)" \a \\a But the FAQ does not break down the parsing rules that lead to this…
Jonah
  • 15,806
  • 22
  • 87
  • 161
13
votes
4 answers

Problem with backticks in shellscript

I am having a problem getting my shellscript working using backticks. Here is an example version of the script I am having an issue with: #!/bin/sh ECHO_TEXT="Echo this" ECHO_CMD="echo ${ECHO_TEXT} | awk -F' ' '{print…
benw
  • 887
  • 2
  • 8
  • 20
12
votes
2 answers

How do I mock Perl's built-in backticks operator?

I'd like to unit test a Perl program of mine that is using backticks. Is there a way to mock the backticks so that they would do something different from executing the external command? Another question shows what I need, but in Ruby. Unfortunately,…
Jonas Wagner
  • 358
  • 3
  • 10
12
votes
2 answers

What does backtick mean in LISP?

I have this macro, which rewrites define. If I remove the " ` " backtick it won't work. What is the explanation? (defmacro define ((name &rest r) body) `(defun ,name ,r ,body))
Alex
  • 357
  • 2
  • 15
11
votes
1 answer

Rmarkdown: writing inline dplyr code if column names have spaces defined with backticks

Problem My inline code chunk breaks when I filter() or select() a column name that has white space that I would normally define with backticks in dplyr. Example Data ```{r setup, include=FALSE} knitr::opts_chunk$set(echo = TRUE) …
sullij
  • 196
  • 8
11
votes
2 answers

Makefile $(command) not working but `command` did

The thing is when I was writing a Makefile for my project, when I needed to detect the current branch name, in a make rule I did this : check_branch: if [ "$(git rev-parse --abbrev-ref HEAD)" == "master" ]; then \ echo "In master" else…
phnah
  • 1,711
  • 1
  • 15
  • 21
1
2
3
20 21