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
4
votes
5 answers

perl - using backticks instead of system()

I have a perl script that calls an other perl script by using system() it's like: my $returnval= system("perl", $path,$val1, $val2,@myarray); Because system() returns only the exit status but I want the script's output I want to use backticks. I…
Tyzak
  • 2,430
  • 8
  • 38
  • 52
3
votes
4 answers

Use of pipes in backticks

I'm trying to run a command with a pipe but receive errors: echo abc | `echo "grep a | grep b"` grep: |: No such file or directory grep: grep: No such file or directory grep: b: No such file or directory What is wrong with the code? Expected…
Trent
  • 2,328
  • 3
  • 33
  • 51
3
votes
1 answer

Mysql not giving Syntax error when it should

I am trying with following query SELECT COUNT(*) FROM users` WHERE email = 'xyz@xyz.com' This is not giving me syntax error (notice not include ` character at the starting of table name). And always gives me count as 1, although record in not…
jimy
  • 4,848
  • 3
  • 35
  • 52
3
votes
3 answers

How to pass shell wildcards into a backtick command

I am trying to use find in a shell script to count the number of files I have matching a wildcard pattern, then to get the name of the file if there is only one. But I'm having trouble passing the wildcard pattern through to backtick…
blueshift
  • 6,742
  • 2
  • 39
  • 63
3
votes
2 answers

Operator on do indentation

hindent changed my code to: do download i inputFile onException (callProcess (List.head args) (List.tail args)) (removeFileIfExists name) `finally` removeFileIfExists inputFile I can't determine if the finally applies to the rest of…
Matt Joiner
  • 112,946
  • 110
  • 377
  • 526
3
votes
1 answer

In `irb`, backticks throw an exception, but in `rails c`, they don't

OS: Debian GNU/Linux 8 Ruby version: 2.4.1 Rails version: 5.1.4 I just used rails new to create a brand new Rails project. In its directory, with irb, I tried to execute a shell command for an executable that did not exist, and an exception was…
Jackson
  • 9,188
  • 6
  • 52
  • 77
3
votes
5 answers

Escape whitespace when using backticks

I've had a search around, and from my perspective using backticks is the only way I can solve this problem. I'm trying to call the mdls command from Perl for each file in a directory to find it's last accessed time. The issue I'm having is that in…
user271528
3
votes
1 answer

Type backtick in shell string variable

Can anyone tell me how I can type a backtick in my shell variable? I am building a SQL query in a variable. The column name for that query is also a variable and i need to put it between backticks (it has to be a backtick, not a ' or a…
Tjekkles
  • 5,352
  • 8
  • 36
  • 53
3
votes
4 answers

Why doesn't my if statement with backticks work properly?

I am trying to make a Bash script where the user will be able to copy a file, and see if it was successfully done or not. But every time the copy is done, properly or not, the second output "copy was not done" is shown. Any idea how to solve…
Tomb_Raider_Legend
  • 431
  • 13
  • 29
3
votes
2 answers

Why does PHP backticks and SSH not return identical values?

When I run ps cax with my ssh command line, I get the following: user@dqeb ~ $ ps cax PID TTY STAT TIME COMMAND 3277 ? Ss 12:51 httpd 6797 ? S 1:45 httpd 7190 ? Ss 0:00 gpopd.pl 7291 ? S 0:02…
Coert Grobbelaar
  • 627
  • 4
  • 14
3
votes
3 answers

creating a file downloading script with checksum verification

I want to create a shellscript that reads files from a .diz file, where information about various source files are stored, that are needed to compile a certain piece of software (imagemagick in this case). i am using Mac OSX Leopard 10.5 for this…
z3cko
  • 3,054
  • 8
  • 40
  • 59
3
votes
3 answers

Why does my Perl backticks complain "sh: line 1: any: command not found"?

I've never programmed before, but needed to write a very simple webapp for work. I'm trying to get this dig query to work: dig @8.8.8.8 +nocomments +nostats +noquestion +nocmd google.com any With this bit of perl: $dig = `/usr/bin/dig \@8.8.8.8…
scraft3613
  • 247
  • 4
  • 9
3
votes
1 answer

Understand how to use backtick with notepad(MS)

if I do with powershell that [string]$text = "this `nis a `ntest" $text > c:\test.txt with notepad++ this is the result: this is a test but if I open it with notepad of windows it doesn't work: this is a test why that?…
rschirin
  • 1,939
  • 10
  • 34
  • 44
3
votes
2 answers

Chef recipe: can't capture output from backticks to variable in ruby_block

I have a Chef recipe with a ruby_block containing this: myoutput = `keytool -import -alias #{al} -keystore #{ks} -storepass #{pw} -file #{ca} -trustcacerts -noprompt` puts ":" + myoutput + ":" Chef::Log.error('Error installing CA Cert') unless…
f8ster
  • 97
  • 1
  • 11
3
votes
1 answer

shell script can not save output from command line into variable

i'm trying to do shell command then save the output into variable using shell script. So i use backticks like this : out=`ls -l` print $out that code is working fine,and i can use it for any other shell command, but when i try to do 'python…
andio
  • 1,574
  • 9
  • 26
  • 45