diff --git a/book/stdout_stderr_exit_codes.md b/book/stdout_stderr_exit_codes.md index 1d460c9bc97..682af2332be 100644 --- a/book/stdout_stderr_exit_codes.md +++ b/book/stdout_stderr_exit_codes.md @@ -99,10 +99,9 @@ use std cat unknown.txt o+e> (std null-device) ``` -Semicolons follow defined pipeline behavior. In the following example, the first expression prints to stdout, and the second becomes the result of the parentheses-subexpression and gets piped into `out.txt`. +Semicolons follow defined pipeline behavior. In the following example, the first external command prints to stdout, and the second external command stdout becomes the output of the parentheses-subexpression and gets piped into `out.txt`. ```nu -let text = "hello\nworld" -($text | head -n 1; $text | tail -n 1) o> out.txt +(nu -c 'print hello'; nu -c 'print world') o> test.txt # => hello open out.txt # => world @@ -117,6 +116,13 @@ open out.txt # => world ``` +This external command behavior is in contrast to native Nushell expressions where the first command's stdout gets discarded: +```nu +('hello'; 'world') o> test.txt +open test.txt +# => world +``` + ## Pipe Redirections If a regular pipe `|` comes after an external command, it redirects the stdout of the external command as input to the next command. To instead redirect the stderr of the external command, you can use the stderr pipe, `err>|` or `e>|`: