The case against backticks
I hate backticks. They have no place in modern shell programming. Here is a couple of reasons why this is the case.
Not nestable
backticks, by their nature, are not nestable. You can not have a command expansion inside another with back ticks.
command `foo ` bar ` baz`
Should the shell expand foo and baz or bar and then foo <output of bar> baz? As it happens it will run the first one. Using the modern command expansion syntax you can write:
command $(foo $( bar ) baz)
command $(foo ) bar $( baz)
Backticks are invisible
The backtick symbol is too small and too easily confused with a single quote to be used for writing maintainable code. The alternative is significantly larger and therefore more obvious.
ls "'`!!`'"
ls "'$(!!)'"
Here is a zoomed version of the line above in my terminal:

Please consider using the bracketed version of command expansion rather than backticks and make the world a nicer place
Filed under shell
10 comments
Comments are closed. These are preserved from the original site.
That means that, at least for GNU stuff we have to avoid it (the goal is for the apps to build on pretty much anything).
Sadly, even in this day and age, Solaris' /bin/sh still isn't POSIX, which undermines the value of having a standard.
/me ducks, runs
I don't know about you, but I do an awful lot of shell programming, mostly because most of the time it's the quickest and easiest way of automating something.
Solaris has a couple of these oddities. Which is extremely odd because Solaris is one of the few Unices that is still developed and can be considered modern. Nonetheless it doesn't support trivial things like this which were even supported by now discontinued unices. This a lot of Java-related issues are reason why I developed a strong antipathy against Sun.
command `foo `bar` blah`
you can even nest more by escaping yet again...
command `foo `bar \`zoing\`` blah`
etc.
Admittedly it's not as pretty as the newer way.
Your first argument is totally invalid unless you're doing something like ssh user@lala "for i in `cat /home/user/omglist` ; do awk '($1>=200) {print $1}'; done". It can be escaped nearly everywhere else. And your second argument is just anal, buy some glasses.
Only programmer zealots hate backticks, which makes me wonder why you're even using bash?
# ls -li /usr/xpg4/bin/sh /bin/ksh
307 -r-xr-xr-x 3 root bin 209288 Jan 25 2008 /bin/ksh
13512 -r-xr-xr-x 1 root bin 209288 Jan 25 2008 /usr/xpg4/bin/sh
And if you can't tell the difference between the various quote marks, you need to be using a better font.
I for one detest backticks. I didn't hate bash altogether, at least not at first, but I must also say that the syntax of the case/switch statement it's fairly horrid. That said, I'm attempting to learn some C++ and am well fed up with writing compounded if/else statements. I'm also not a zealot, not even about my beloved bourbon.
buy zanaflex