LinuxSelfhelp.com

3.3. Command Substitution

In almost all cases in this document, I use the $(<command>) convention for command substitution: that is,

$(date +%H%M)

means "substitute the output from the date +%H%M command here." This works in Bash 2.0+. In some older versions of Bash, prior to 1.14.7, you may need to use backquotes (`date +%H%M`). Backquotes can be used in Bash 2.0+, but are being phased out in favor of $(), which nests better. If you're using an earlier version of Bash, you can usually substitute backquotes where you see $(). If the command substitution is escaped (ie. \$(command) ), then use backslashes to escape BOTH your backquotes (ie. \'command\' ).