Using backticks or dollar in shell scripts

Solution 1:

Use dollar. Backticks are semi-deprecated, because they are more complicated to use (see the link), and there are no advantages to them unless you're doing code golf and absolutely need to save a single character. They probably won't be removed from popular shells anytime soon though, so you're safe using either for now.

Solution 2:

Stick with the dollar sign notation $() whenever you can. Backticks get cumbersome/confusing when you start needing to do nested quoting. Ex:

$ FOO=`echo "foo's"`
$ echo $FOO
foo's

Replacing the backticks with $() yields the same output, and is easier to read (fewer quotes of varrying angles to discern):

$ FOO=$(echo "foo's")
$ echo $FOO
foo's

That, and each quotation mark (single quote, double quote, backtick) means something different in the shell, so using $ can help remove a level of complexity. And the developer who follows you will thank you, for he/she will have an easier time figuring out what you did.