Print header.txt followed by body.txt to standard output.
Do not modify either input file.
Which command is correct?
cat reads its file arguments in order and writes their contents to standard output. Without redirection, the inputs are not modified.
Detailed explanation
cat header.txt body.txtCorrect. cat writes header.txt and then body.txt in that order.
Correct. cat writes header.txt and then body.txt in that order.
cat body.txt header.txtIncorrect. The output order is reversed.
Incorrect. The output order is reversed.
head header.txt body.txtIncorrect. head is for showing file prefixes and is not the general concatenation command.
Incorrect. head is for showing file prefixes and is not the general concatenation command.
paste header.txt body.txtIncorrect. paste combines files side by side rather than appending their contents.
Incorrect. paste combines files side by side rather than appending their contents.
Try it yourself
An example you can run in a temporary verification environment.
printf 'HEADER
' > /tmp/kp-header.txt
printf 'BODY
' > /tmp/kp-body.txt
cat /tmp/kp-header.txt /tmp/kp-body.txt
rm /tmp/kp-header.txt /tmp/kp-body.txtExpected result
HEADER
BODYKey points
- cat concatenates file contents
- Argument order determines output order
- 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.