Run: run-check 2>&1 > output.log
Determine where each stream normally goes.
Which result is appropriate?
2>&1 copies the current stdout connection first; the later > output.log changes stdout only, leaving stderr on the original terminal.
Detailed explanation
Incorrect. stderr was copied before stdout moved to output.log.
Correct. stdout goes to output.log while stderr retains the original terminal connection.
Incorrect. The command does not use 2> output.log.
Incorrect. Neither stream is connected to /dev/null.
Try it yourself
An example you can run in a temporary verification environment.
tmp=$(mktemp); captured=$(sh -c 'echo out; echo err >&2' 2>&1 >"$tmp"); printf 'terminal=%s file=%s\n' "$captured" "$(cat "$tmp")"; rm -f "$tmp"Expected result
terminal=err file=outKey points
- 2>&1 copies the current connection
- A later > changes stdout only
- Order changes the result
Notes
- Environment: POSIX shell / 一時ファイルとcommand substitution
- Use temporary files and harmless commands for stream experiments.
- Shell redirection syntax and xargs behavior should be checked on the target shell implementation.
Foundation review
Place the operation
Two visually similar redirection lists can differ because descriptor 2 may copy an earlier or later destination.
Check the side effect
Draw a descriptor table before running the command, then verify with separate test messages.