Print header.txt, body.txt, and footer.txt to standard output in that order.
Which command is appropriate?
cat reads each file in argument order and writes their contents consecutively to the same standard output.
Detailed explanation
cat header.txt body.txt footer.txtCorrect. cat header.txt body.txt footer.txt prints the files in the requested order.
Correct. cat header.txt body.txt footer.txt prints the files in the requested order.
paste header.txt body.txt footer.txtIncorrect. paste combines corresponding lines horizontally.
Incorrect. paste combines corresponding lines horizontally.
join header.txt body.txt footer.txtIncorrect. join matches fields in two files rather than simply concatenating three files.
Incorrect. join matches fields in two files rather than simply concatenating three files.
sort header.txt body.txt footer.txtIncorrect. sort reorders input lines and does not preserve file order.
Incorrect. sort reorders input lines and does not preserve file order.
Try it yourself
An example you can run in a temporary verification environment.
tmp=$(mktemp -d); printf 'H\n' >"$tmp/h"; printf 'B\n' >"$tmp/b"; printf 'F\n' >"$tmp/f"; cat "$tmp/h" "$tmp/b" "$tmp/f"; rm -rf "$tmp"Expected result
H
B
FKey points
- cat concatenates vertically
- Argument order is preserved
- Output goes to standard output
Notes
- Environment: GNU coreutils 9.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.