Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions book/stdout_stderr_exit_codes.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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>|`:
Expand Down