LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 05-19-2015, 01:00 PM   #16
genss
Member
 
Registered: Nov 2013
Posts: 741

Rep: Reputation: Disabled

i use backtics as it's much easier to write
for nested id use $()

last i checked ` is still in POSIX
 
Old 05-19-2015, 01:26 PM   #17
millgates
Member
 
Registered: Feb 2009
Location: 192.168.x.x
Distribution: Slackware
Posts: 852

Rep: Reputation: 389Reputation: 389Reputation: 389Reputation: 389
Usage of the $() is generally recommended in bash, but I wouldn't go as far as calling backticks deprecated.
Regarding compatibility issues, $() is a part of POSIX, so I wouldn't wory about anything but very old systems.
Personally, I prefer $() and usually recommend it over the backticks. Now both can do the same, so if anyone prefers backticks, I'm fine with that.
In addition to the advantages already mentioned, Here's a few other things I like about the "new" syntax:

1/ Consistent syntax with the other "variable-like" expressions:
Code:
$foo     # a variable
${foo,,} # a variable obtained from string manipulation
$((foo)) # a variable obtained from an arithmetic expression
$(foo)   # a variable obtained from a command
$(<foo)  # a variable obtained from a file
2/ Most of the times you use command substitution, you should put it within double quotes, and (in my opinion)
Code:
"$(foo "a b")"
is nicer and more readable than
Code:
"`foo "a b"'"
3/ most text editors will highlight matching pairs of parentheses, but not backticks.
 
Old 05-19-2015, 07:18 PM   #18
Keith Hedger
Senior Member
 
Registered: Jun 2010
Location: Wiltshire, UK
Distribution: Void, Linux From Scratch, Slackware64
Posts: 3,150

Rep: Reputation: 856Reputation: 856Reputation: 856Reputation: 856Reputation: 856Reputation: 856Reputation: 856
Back when I was using OSX and starting to use the shell, I found that when typing some examples they didn't work but copying and pasting did, it took me ages to realize that there is a difference between ' and `. It can be confusing to a newb so I would always use $() especially when posting code examples on this forum, $() has been in POSIX for ages now so I don't see the point of using bacticks when $() is much easier to read, depending on your font ' and ` can be almost indistinguishable, especially for those ( like me ) that have bad eysight.
 
Old 05-21-2015, 10:12 AM   #19
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,831
Blog Entries: 15

Rep: Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669
Quote:
Originally Posted by rnturn View Post
I think Coherent had a Korn variant (pdksh?) but I never used it.
In RHEL4 they had pdksh rather than ksh available and it worked well enough. Starting with RHEL5 they have true ksh.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
error "vga=768" deprecated from GRUB-2 on Ubuntu Karmic SaintDanBert Linux - Software 5 02-04-2010 03:37 PM
C function "times()" -- what is considered system time? gratuitous_arp Programming 2 01-07-2010 08:50 PM
"Not a CODE" reference error perl v5.10.0, Deprecated assignment operation. skuletm Programming 3 03-12-2009 12:21 AM
Error "'qla2x00_callback': function not considered for" while installing kernel 2.6.9 angelshines Linux - Kernel 1 04-06-2008 12:41 PM
Is ".gz" archive file considered "World-Readable"? NightSky Linux - Newbie 4 12-06-2007 05:21 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:55 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration