Shell originally used only backticks for command substitution:
less `find . -type f`
But these do not nest and suffer from other problems. Bash (and probably ksh, but I’m not up on the history there) used $()
as a newer, improved command substitution.
But that explains the difference and while the filetype matters—in fact, the shebang (#!
line) matters! If you use /bin/sh
, you should only use POSIX sh
features. Otherwise, use the path to a known interpreter and use it’s features.
As pointed out in the comments, POSIX allows the newer command substitution, so it should be safe even in sh
scripts.