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.
Incorrect. > truncates the existing log.
check-status >> history.logCorrect. >> appends standard output to history.log.
Correct. >> appends standard output to history.log.
check-status 2>> history.logIncorrect. 2>> appends standard error, not standard output.
Incorrect. 2>> appends standard error, not standard output.
check-status < history.logIncorrect. < supplies history.log as standard input.
Incorrect. < 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 / 一時ファイル
- Command output formatting can vary slightly by distribution or tool version.
- Run the example in a temporary directory or process when possible.
Foundation review
Read the scope first
Check whether the command acts on the current shell, a new process, an existing process, or a file.
Verify the observable result
Use the supplied command and compare the output with the expected result.