Differences between revisions 1 and 25 (spanning 24 versions)
Revision 1 as of 2007-05-09 18:10:44
Size: 788
Editor: GreyCat
Comment: new question
Revision 25 as of 2016-03-22 13:56:08
Size: 399
Editor: RomaRancou
Comment:
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
[[Anchor(faq82)]]
== Why is $(...) preferred over `` (backticks)? ==

For several reasons:

 * It makes nesting command substitutions easier. Compare:

  {{{
  x=$(grep $(dirname "$path") file)
  x=`grep \`dirname "$path"\` file`}}}

 It just gets uglier and uglier after two levels.

 * It's easier to read.
 * Newbies who see {{{$()}}} don't normally press the wrong keys. On the other hand, newbie who see {{{`cmd`}}} often mangle it into {{{'cmd'}}} because they don't know what a backtick is.
 * Backslashes (\) inside backticks are handled in a non-obvious manner. ''(Example desired!)'' Inside {{{$()}}}, there are no such surprises.

The only time backticks are preferred is when writing code for the oldest Bourne shells, which do not know about {{{$()}}}.
Heya. The name is senaida pruitt. At the moment i live in hollywood. I am turning 50. i and my sister go to the special academy situated in exeter. i am self employed as a curator. my hobby is tea tasting. My papas name is jeff and he is a musician. My mother works as a manicure.<<BR>><<BR>>
<<BR>><<BR>>
Also visit my web-site; [[http://homesafetydot.com/security-lighting/|homesafetydot.com]]

Heya. The name is senaida pruitt. At the moment i live in hollywood. I am turning 50. i and my sister go to the special academy situated in exeter. i am self employed as a curator. my hobby is tea tasting. My papas name is jeff and he is a musician. My mother works as a manicure.



Also visit my web-site; homesafetydot.com

BashFAQ/082 (last edited 2022-02-19 00:13:59 by larryv)