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.
paste header.txt body.txt footer.txtIncorrect. paste combines corresponding lines horizontally.
join header.txt body.txt footer.txtIncorrect. 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.
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 / 一時テキスト
- Use small, disposable text streams when testing filters.
- Locale, encoding, and GNU/POSIX implementation details can affect edge cases.
Foundation review
Place the operation
cat is a simple stream concatenator; it does not add record-aware separators unless the input contains them.
Check the side effect
Use small text files and inspect boundaries when checking the resulting stream.