Skip to main content
added 36 characters in body
Source Link
Kusalananda
  • 355.9k
  • 42
  • 735
  • 1.1k

A "compound command" can also be redirected, obviously. A compound command is a pipeline (possibly a single simple command) in a { ...; } brace group, or in a ( ... ) subshell, or an if, while, for, until, or a case statement, or a ( ... ) subshell.

A "compound command" can also be redirected, obviously. A compound command is a command in { ...; }, or an if, while, for, until, case statement, or a ( ... ) subshell.

A "compound command" can also be redirected, obviously. A compound command is a pipeline (possibly a single simple command) in a { ...; } brace group, or in a ( ... ) subshell, or an if, while, for, until, or a case statement.

added 185 characters in body
Source Link
Kusalananda
  • 355.9k
  • 42
  • 735
  • 1.1k

Individual simple commands (see below) may be redirected:

$ echo hello | { read message && printf 'We got "%s"\n' "$message"; echo bye >&2; } | rev
bye
"olleh" tog eW

The redirection, on the other hand, binds quite tightly to the current command as the grammar makes the redirection part of a "simple command" construct. A simple command is some command prefix, the name of a command, and a command suffix (where prefix and suffix are optional). A command prefix may be an assignment to an environment variable (VAR=value myscript), or a redirection (>outfile cat). Likewise a command suffix may be a redirection (cat >outfile), etc.

A "compound command" can also be redirected, obviously. A compound command is a command in { ...; }, or an if, while, for, until, case statement, or a ( ... ) subshell.

The redirection, on the other hand, binds quite tightly to the current command as the grammar makes the redirection part of a "simple command" construct. A simple command is some command prefix, the name of a command, and a command suffix (where prefix and suffix are optional). A command prefix may be an assignment to an environment variable (VAR=value myscript), or a redirection (>outfile cat). Likewise a command suffix may be a redirection (cat >outfile), etc.

Individual simple commands (see below) may be redirected:

$ echo hello | { read message && printf 'We got "%s"\n' "$message"; echo bye >&2; } | rev
bye
"olleh" tog eW

The redirection, on the other hand, binds quite tightly to the current command as the grammar makes the redirection part of a "simple command" construct. A simple command is some command prefix, the name of a command, and a command suffix (where prefix and suffix are optional). A command prefix may be an assignment to an environment variable (VAR=value myscript), or a redirection (>outfile cat). Likewise a command suffix may be a redirection (cat >outfile), etc.

A "compound command" can also be redirected, obviously. A compound command is a command in { ...; }, or an if, while, for, until, case statement, or a ( ... ) subshell.

edited body
Source Link
Kusalananda
  • 355.9k
  • 42
  • 735
  • 1.1k

which means the output of command1 is piped to the compound command command1command2 && command2command3. The output of the compound command is then piped to command3command4:

The redirection, on the other hand, binds quite tightly to the current command as the grammar makes the redirection part of a "simple command" construct. A simple command is some command prefix, the name of a command command, and a command suffix (where prefix and suffix are optional). A command prefix may be an assignment to an environment variable (VAR=value myscript), or a redirection (>outfile cat). Likewise a command suffix may be a redirection (cat >outfile), etc.

which means the output of command1 is piped to the compound command command1 && command2. The output of the compound command is then piped to command3:

The redirection, on the other hand, binds quite tightly to the current command as the grammar makes the redirection part of a "simple command" construct. A simple command is some command prefix, a command, and a command suffix (where prefix and suffix are optional). A command prefix may be an assignment to an environment variable (VAR=value myscript), or a redirection (>outfile cat). Likewise a command suffix may be a redirection (cat >outfile), etc.

which means the output of command1 is piped to the compound command command2 && command3. The output of the compound command is then piped to command4:

The redirection, on the other hand, binds quite tightly to the current command as the grammar makes the redirection part of a "simple command" construct. A simple command is some command prefix, the name of a command, and a command suffix (where prefix and suffix are optional). A command prefix may be an assignment to an environment variable (VAR=value myscript), or a redirection (>outfile cat). Likewise a command suffix may be a redirection (cat >outfile), etc.

added 1243 characters in body
Source Link
Kusalananda
  • 355.9k
  • 42
  • 735
  • 1.1k
Loading
added 1243 characters in body
Source Link
Kusalananda
  • 355.9k
  • 42
  • 735
  • 1.1k
Loading
Source Link
Kusalananda
  • 355.9k
  • 42
  • 735
  • 1.1k
Loading