Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Backtick
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== Computing == === Command-line interface languages === Many [[List of programming languages by type#Command-line interface languages|command-line interface languages]] and the [[scripting languages|scripting (programming) languages]] like [[Perl]], [[PHP]], [[Ruby (programming language)|Ruby]] and [[Julia (programming language)|Julia]] (though see below) use pairs of backticks to indicate [[command substitution]]. A command substitution is the [[standard output]] from one command, into an embedded line of text within another command.<ref>{{cite web|url=https://mywiki.wooledge.org/CommandSubstitution|title=Command Substitution|website=wooledge.org|access-date=2024-08-06}}</ref><ref>{{cite web|url=http://zsh.sourceforge.net/Intro/intro_7.html|title=An Introduction to the Z Shell β Command/Process Substitution|website=zsh.sourceforge.net|access-date=27 March 2018}}</ref> For example, using $ as the symbol representing a terminal prompt, the code line: : {{sxhl|2=console|$ echo "It is now `date`" It is now {{#time:D M j H:i:s e Y}}}} In all POSIX [[Shell (computing)|shell]]s (including [[Bash (Unix shell)|Bash]] and [[Z shell|Zsh]]), the use of backticks for command substitution is now largely deprecated in favor of the notation <code>$(...)</code>, so that the example above would be re-written: : {{sxhl|2=console|$ echo "It is now $(date)"}} The new syntax allows nesting, for example: : {{sxhl|2=console|$ echo "An absolute path to the 'zcat' command is $( readlink -e "$( type -P zcat )" )" An absolute path to the 'zcat' command is /usr/bin/gzip}} === Markup languages === It is sometimes used in [[source code comments]] to indicate code, e.g., : <pre>/* Use the `printf()` function. */</pre> This is also the format the [[Markdown]] formatter uses to indicate code.<ref>{{Cite web|url=http://daringfireball.net/projects/markdown/syntax#code|title = Daring Fireball: Markdown Syntax Documentation}}</ref> Some variations of Markdown support "fenced code blocks" that span multiple lines of code, starting (and ending) with three backticks in a row (<code>```</code>).<ref>{{cite web |url=https://github.github.com/gfm/#fenced-code-blocks |title=GitHub Flavored Markdown Spec |access-date=23 February 2022 |archive-url=https://web.archive.org/web/20220221045705/https://github.github.com/gfm/#fenced-code-blocks |archive-date=21 February 2022 |url-status=live}}</ref> * [[TeX]]: The backtick character represents curly opening quotes. For example, <code>`</code> is rendered as single opening curly quote ({{not a typo|β}}) and <code>``</code> is a double curly opening quote ({{not a typo|β}}). It also supplies the numeric ASCII value of an ASCII character wherever a number is expected. === Programming languages === * [[BBC BASIC]]: The backtick character is valid at the beginning of or within a variable, structure, procedure or function name. * [[D (programming language)|D]] and [[Go (programming language)|Go]]: The backtick surrounds a [[String literal#Raw strings|raw string literal]]. * [[F Sharp (programming language)|F#]]: Surrounding an identifier with double backticks allows the use of identifiers that would not otherwise be allowed, such as keywords, or identifiers containing punctuation or spaces. * [[Haskell (programming language)|Haskell]]: Surrounding a function name by backticks makes it an [[infix notation|infix operator]]. * [[JavaScript]]: [[ECMAScript 6]] standard introduced a "backtick"<ref>{{Cite web|url=https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals|title=Template literals (Template strings)|website=MDN Web Docs|language=en|access-date=2019-05-22}}</ref> character which indicated a string or [[String interpolation|template literal]]. Its applications include (but are not limited to): string interpolation (substitution), embedded expressions, and multi-line strings. In the following example <code>name</code> and <code>pet</code> variable's values get substituted into the string enclosed by grave accent characters: ::<syntaxhighlight lang="js"> const name = "Mary", pet = "lamb"; // Set variables let temp = `${name} has a little ${pet}!`; console.log(temp); // => "Mary has a little lamb!"; </syntaxhighlight> * [[Lisp (programming language)|Lisp]] [[macro (computer science)|macro]] systems: The backtick character (called ''quasiquote'' in [[Scheme (programming language)|Scheme]]) introduces a quoted expression in which comma-substitution may occur. It is identical to the plain quote, except that a nested expression prefixed with a [[comma (punctuation)|comma]] is replaced with the value of that nested expression. If the nested expression happens to be a symbol (that is, a variable name in Lisp), the symbols' value is used. If the expression happens to be program code, the first value returned by that code is inserted at the respective location instead of the comma-prefixed code. This is roughly analogous to the Bourne shell's [[variable interpolation]] with <CODE>$</CODE> inside double quotes. * [[Julia (programming language)|Julia]]: Backticks make a command object, <code>Cmd</code>, that can be run, with run function, like <code>run(`echo Hello world!`)</code>. You can interpolate Julia variables, but only indirectly shell environment variables. * [[m4 (computer language)|m4]]: A backtick together with an apostrophe quotes strings (to suppress or defer macro expansion). * [[MySQL]]/[[MariaDB]]: A backtick in queries is a delimiter for column, table, and database identifiers. * [[OCaml]]: The backtick indicates polymorphic variants. * [[Pico programming language|Pico]]: The backtick indicates comments in the programming language. * [[PowerShell]]: The backtick is used as the escape character. For example, a newline character is denoted <code>`n</code>. Most common programming languages use a backslash as the escape character (e.g., <code>\n</code>), but because Windows allows the backslash as a path separator, it is impractical for PowerShell to use backslash for a different purpose. Two backticks produce the <code>`</code> character itself. For example, the [[Nullable type|nullable]] [[Boolean data type|boolean]] of [[.NET Framework|.NET]] is specified in PowerShell as <code>[Nullable``1[System.Boolean]]</code>. * [[Python (programming language)|Python]]: Prior to version 3.0, backticks were a synonym for the <code>repr()</code> function, which converts its argument to a string suitable for a programmer to view. However, this feature was removed in Python 3.0. Backticks also appear extensively in the [[reStructuredText]] plain text markup language (implemented in the Python [[docutils]] package). * [[R (programming language)|R]]: The backtick is used to surround non-syntactic variable names. This includes variable names containing special characters or [[reserved words]], among others.<ref name="R Documentation">{{Citation |author=R Core Team |title=Quotes: Quotes |publisher=R Foundation for Statistical Computing |url=https://www.rdocumentation.org/packages/base/versions/3.6.2/topics/Quotes|postscript=.}}</ref> * [[Racket (programming language)|Racket]]: The backtick or "Quasiquote" is used to begin creating lists. * [[Scala (programming language)|Scala]]: An identifier may also be formed by an arbitrary string between backticks. The identifier then is composed of all characters excluding the backticks themselves.<ref>{{Citation| last = Odersky| first = Martin| title = The Scala Language Specification Version 2.9| date = 2011-05-24}}</ref> * [[Tom (pattern matching language)|Tom]]: The backtick creates a new term or to calls an existing term. * [[Unlambda]]: The backtick character denotes function application. * [[Verilog]] [[hardware description language|HDL]]: The backtick is used at the beginning of compiler's directives.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)