Skip to main content
deleted 224 characters in body
Source Link
Joseph R.
  • 40.6k
  • 8
  • 115
  • 146

The $() syntax is called command substitution and the shell treats it by first executing the command inside the parentheses then assigning its stdout (with trailing newlines removed) to x1.

In other words, the command is executed even before you echo "$x1".

Incidentally, you should quote command substitution to avoid word splitting:

x1="$(...)" 

For the echo the quotes, though harmless, are unnecessary as echo is happy to work with any number of arguments.

The $() syntax is called command substitution and the shell treats it by first executing the command inside the parentheses then assigning its stdout (with trailing newlines removed) to x1.

In other words, the command is executed even before you echo "$x1".

Incidentally, you should quote command substitution to avoid word splitting:

x1="$(...)" 

For the echo the quotes, though harmless, are unnecessary as echo is happy to work with any number of arguments.

The $() syntax is called command substitution and the shell treats it by first executing the command inside the parentheses then assigning its stdout (with trailing newlines removed) to x1.

In other words, the command is executed even before you echo "$x1".

deleted 1 character in body
Source Link
Joseph R.
  • 40.6k
  • 8
  • 115
  • 146

The $() syntax is called command substitution and the shell treats it by first executing the command inside the parentheses then assigning its stdout (with trailing whitespacenewlines removed) to x1.

In other words, the command is executed even before you echo "$x1".

Incidentally, you should quote command substitution to avoid word splitting:

x1="$(...)" 

For the echo the quotes, though harmless, are unnecessary as echo is happy to work with any number of arguments.

The $() syntax is called command substitution and the shell treats it by first executing the command inside the parentheses then assigning its stdout (with trailing whitespace removed to x1.

In other words, the command is executed even before you echo "$x1".

Incidentally, you should quote command substitution to avoid word splitting:

x1="$(...)" 

For the echo the quotes, though harmless, are unnecessary as echo is happy to work with any number of arguments.

The $() syntax is called command substitution and the shell treats it by first executing the command inside the parentheses then assigning its stdout (with trailing newlines removed) to x1.

In other words, the command is executed even before you echo "$x1".

Incidentally, you should quote command substitution to avoid word splitting:

x1="$(...)" 

For the echo the quotes, though harmless, are unnecessary as echo is happy to work with any number of arguments.

Source Link
Joseph R.
  • 40.6k
  • 8
  • 115
  • 146

The $() syntax is called command substitution and the shell treats it by first executing the command inside the parentheses then assigning its stdout (with trailing whitespace removed to x1.

In other words, the command is executed even before you echo "$x1".

Incidentally, you should quote command substitution to avoid word splitting:

x1="$(...)" 

For the echo the quotes, though harmless, are unnecessary as echo is happy to work with any number of arguments.