Difference between $() and ``

Hello,
Are these 2 different ?

1
2
3
content=`cat file`

content=$(cat file)


when I echo them out , I receive the same result , but does shell handle them
the same ? or not ?

Thanks
Last edited on
Which shell? Bash?

Read section "Command substitution" from
man bash
If you could tell me for both that would be great
I just did.

I will not copy text here, because you are better off by learning to read the manual.

Note: man-pages are online too, if you don't have them installed.
They are identical in bash.
Google: Advanced Bash Scripting
Last edited on
In the Korn shell, the grave accents style ('') is obsolete. It's also slower than $().
http://www.gnu.org/software/bash/manual/bashref.html#Command-Substitution writes:
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 substitution. 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.

I.e. not identical.
Topic archived. No new replies allowed.