I'v run both commands and they both seem to do the same thing, is this true or is there something happening I'm not seeing?
These two appear to do the same thing:
result=$(ls -l)
result=`ls -l`
I'v run both commands and they both seem to do the same thing, is this true or is there something happening I'm not seeing?
These two appear to do the same thing:
result=$(ls -l)
result=`ls -l`
Hi,
Please check out http://nixcraft.com/shell-scripting/13288-loop-input-backticks-vs-differences.html#post19804 for a nice explanation of this case.
The bash man page says the following, under Command Substitution.
When the old-style backquote form of substitution is used, backslash retains its literal meaning except when followed by $, `, or . The first backquote not preceded by a backslash terminates the command sub-stitution. When using the $(command) form, all characters between the parentheses make up the command; none are treated specially.
Command substitutions may be nested. To nest when using the backquoted form, escape the inner backquotes with backslashes.
Online copies of the sh man page: