Skip to main content
Fixed formatting and typo.
Source Link

From the manual (man bash):

$(command) or `command`$(command)  or  `command`

Bash performs the expansion by executing commandcommand and replacing the command substitution with the standard output of the command, with any trailing newlines deleted. Embedded newlines are not deleted, but they may be removed during word splitting. The The command substitution $(cat > file)$(cat file) can be replaced by the equivalent but faster $(< file)$(< file).

When the old-style backquote form of substitution is used, backslash retains its literal meaning except when followed by $$, ``, or \. The firstThe first backquote not preceded by a backslash terminates the command substitution. When using the $(command)$(command) form, all characters between the parentheses make up the command; none are treated specially.

The POSIX standard defines the $() form of command substitution. $() allows nested commands and looks better (legibility). It should be available on all Bourne shells.

You can read more on IEEE Std 1003.1, Shell Command Language, Section 2.6.3 Command Substitution.

At least one Unix, AIX, has documented that backticks are obsolete. From that link:

Although the backquote syntax is accepted by ksh, it is considered obsolete by the X/Open Portability Guide Issue 4 and POSIX standards. These standards recommend that portable applications use the $(command) syntax.

However, /bin/sh does not have to be POSIX compliant. So there is still sometimes a case for backticks in the real world, as @Jeight points out.

From the manual (man bash):

$(command) or `command`

Bash performs the expansion by executing command and replacing the command substitution with the standard output of the command, with any trailing newlines deleted. Embedded newlines are not deleted, but they may be removed during word splitting. The command substitution $(cat > file) can be replaced by the equivalent but faster $(< file).

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.

The POSIX standard defines the $() form of command substitution. $() allows nested commands and looks better (legibility). It should be available on all Bourne shells.

You can read more on IEEE Std 1003.1, Shell Command Language, Section 2.6.3 Command Substitution.

At least one Unix, AIX, has documented that backticks are obsolete. From that link:

Although the backquote syntax is accepted by ksh, it is considered obsolete by the X/Open Portability Guide Issue 4 and POSIX standards. These standards recommend that portable applications use the $(command) syntax.

However, /bin/sh does not have to be POSIX compliant. So there is still sometimes a case for backticks in the real world, as @Jeight points out.

From the manual (man bash):

$(command)  or  `command`

Bash performs the expansion by executing command and replacing the command substitution with the standard output of the command, with any trailing newlines deleted. Embedded newlines are not deleted, but they may be removed during word splitting. The command substitution $(cat file) can be replaced by the equivalent but faster $(< file).

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.

The POSIX standard defines the $() form of command substitution. $() allows nested commands and looks better (legibility). It should be available on all Bourne shells.

You can read more on IEEE Std 1003.1, Shell Command Language, Section 2.6.3 Command Substitution.

At least one Unix, AIX, has documented that backticks are obsolete. From that link:

Although the backquote syntax is accepted by ksh, it is considered obsolete by the X/Open Portability Guide Issue 4 and POSIX standards. These standards recommend that portable applications use the $(command) syntax.

However, /bin/sh does not have to be POSIX compliant. So there is still sometimes a case for backticks in the real world, as @Jeight points out.

added 149 characters in body
Source Link
Christopher
  • 16.3k
  • 7
  • 56
  • 66

From the manual (man bash):

$(command) or `command`

Bash performs the expansion by executing command and replacing the command substitution with the standard output of the command, with any trailing newlines deleted. Embedded newlines are not deleted, but they may be removed during word splitting. The command substitution $(cat > file) can be replaced by the equivalent but faster $(< file).

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.

The POSIX standard defines the $() form of command substitution. $() allows nested commands and looks better (legibility). It should be available on all Bourne shells.

You can read more on IEEE Std 1003.1, Shell Command Language, Section 2.6.3 Command Substitution.

At least one Unix, AIX, has documented that backticks are obsolete. From that link:

Although the backquote syntax is accepted by ksh, it is considered obsolete by the X/Open Portability Guide Issue 4 and POSIX standards. These standards recommend that portable applications use the $(command) syntax.

However, /bin/sh does not have to be POSIX compliant. So there is still sometimes a case for backticks in the real world, as @Jeight points out.

From the manual (man bash):

$(command) or `command`

Bash performs the expansion by executing command and replacing the command substitution with the standard output of the command, with any trailing newlines deleted. Embedded newlines are not deleted, but they may be removed during word splitting. The command substitution $(cat > file) can be replaced by the equivalent but faster $(< file).

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.

The POSIX standard defines the $() form of command substitution. $() allows nested commands and looks better (legibility). It should be available on all Bourne shells.

You can read more on IEEE Std 1003.1, Shell Command Language, Section 2.6.3 Command Substitution.

At least one Unix, AIX, has documented that backticks are obsolete. From that link:

Although the backquote syntax is accepted by ksh, it is considered obsolete by the X/Open Portability Guide Issue 4 and POSIX standards. These standards recommend that portable applications use the $(command) syntax.

From the manual (man bash):

$(command) or `command`

Bash performs the expansion by executing command and replacing the command substitution with the standard output of the command, with any trailing newlines deleted. Embedded newlines are not deleted, but they may be removed during word splitting. The command substitution $(cat > file) can be replaced by the equivalent but faster $(< file).

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.

The POSIX standard defines the $() form of command substitution. $() allows nested commands and looks better (legibility). It should be available on all Bourne shells.

You can read more on IEEE Std 1003.1, Shell Command Language, Section 2.6.3 Command Substitution.

At least one Unix, AIX, has documented that backticks are obsolete. From that link:

Although the backquote syntax is accepted by ksh, it is considered obsolete by the X/Open Portability Guide Issue 4 and POSIX standards. These standards recommend that portable applications use the $(command) syntax.

However, /bin/sh does not have to be POSIX compliant. So there is still sometimes a case for backticks in the real world, as @Jeight points out.

added reference to aix korn shell backticks obsolete
Source Link
Christopher
  • 16.3k
  • 7
  • 56
  • 66

From the manual (man bash):

$(command) or `command`

Bash performs the expansion by executing command and replacing the command substitution with the standard output of the command, with any trailing newlines deleted. Embedded newlines are not deleted, but they may be removed during word splitting. The command substitution $(cat > file) can be replaced by the equivalent but faster $(< file).

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.

The POSIX standard defines the $() form of command substitution. $() allows nested commands and looks better (legibility). It should be available on all Bourne shells.

So a big benefit of $() is nesting, and of command substitution in general, the acquisition of a variable via dynamic means instead of static, which you showed with one of your examples:

file_list_1="list.txt"

You can read more on IEEE Std 1003.1, Shell Command Language, Section 2.6.3 Command Substitution.

At least one Unix, AIX, has documented that backticks are obsolete. From that link:

Although the backquote syntax is accepted by ksh, it is considered obsolete by the X/Open Portability Guide Issue 4 and POSIX standards. These standards recommend that portable applications use the $(command) syntax.

From the manual (man bash):

$(command) or `command`

Bash performs the expansion by executing command and replacing the command substitution with the standard output of the command, with any trailing newlines deleted. Embedded newlines are not deleted, but they may be removed during word splitting. The command substitution $(cat > file) can be replaced by the equivalent but faster $(< file).

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.

The POSIX standard defines the $() form of command substitution. $() allows nested commands and looks better (legibility). It should be available on all Bourne shells.

So a big benefit of $() is nesting, and of command substitution in general, the acquisition of a variable via dynamic means instead of static, which you showed with one of your examples:

file_list_1="list.txt"

You can read more on IEEE Std 1003.1, Shell Command Language, Section 2.6.3 Command Substitution.

From the manual (man bash):

$(command) or `command`

Bash performs the expansion by executing command and replacing the command substitution with the standard output of the command, with any trailing newlines deleted. Embedded newlines are not deleted, but they may be removed during word splitting. The command substitution $(cat > file) can be replaced by the equivalent but faster $(< file).

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.

The POSIX standard defines the $() form of command substitution. $() allows nested commands and looks better (legibility). It should be available on all Bourne shells.

You can read more on IEEE Std 1003.1, Shell Command Language, Section 2.6.3 Command Substitution.

At least one Unix, AIX, has documented that backticks are obsolete. From that link:

Although the backquote syntax is accepted by ksh, it is considered obsolete by the X/Open Portability Guide Issue 4 and POSIX standards. These standards recommend that portable applications use the $(command) syntax.

corrected rendering of backticks within blockqoute
Source Link
steeldriver
  • 83.8k
  • 12
  • 124
  • 175
Loading
Source Link
Christopher
  • 16.3k
  • 7
  • 56
  • 66
Loading