Append check-status standard output to the end of history.log.
Keep the existing log contents.
Which redirection is appropriate?
>> opens the standard-output destination in append mode, preserving existing contents and writing new output at the end.
Detailed explanation
check-status > history.logIncorrect. > truncates the existing log.
check-status >> history.logCorrect. >> appends standard output to history.log.
check-status 2>> history.logIncorrect. 2>> appends standard error, not standard output.
check-status < history.logIncorrect. < supplies history.log as standard input.
Try it yourself
An example you can run in a temporary verification environment.
tmp=$(mktemp); printf 'old\n' >"$tmp"; printf 'new\n' >>"$tmp"; cat "$tmp"; rm -f "$tmp"Expected result
old
newKey points
- >> means append
- Existing contents remain
- 2>> targets stderr
Notes
- Environment: Bash 5.x / 一時ファイル
- 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
Appending differs from overwrite because the destination is not truncated first.
Check the side effect
Run two small commands and verify that both lines remain in the temporary log.