Combine the lines with the same line numbers from names.txt and scores.txt.
Print the result as comma-separated columns; no key matching is needed.
Which command is appropriate?
paste joins corresponding input lines as columns. Its -d option selects the output delimiter.
Detailed explanation
join -t, names.txt scores.txtIncorrect. join performs key-based matching rather than simple line-number pairing.
Incorrect. join performs key-based matching rather than simple line-number pairing.
paste -d, names.txt scores.txtCorrect. paste -d, names.txt scores.txt joins corresponding lines with commas.
Correct. paste -d, names.txt scores.txt joins corresponding lines with commas.
cat names.txt scores.txtIncorrect. cat concatenates the files vertically.
Incorrect. cat concatenates the files vertically.
cut -d, -f1 names.txt scores.txtIncorrect. cut extracts fields from existing input and does not create a column join.
Incorrect. cut extracts fields from existing input and does not create a column join.
Try it yourself
An example you can run in a temporary verification environment.
tmp=$(mktemp -d); printf 'Alice\nBob\n' >"$tmp/n"; printf '80\n90\n' >"$tmp/s"; paste -d, "$tmp/n" "$tmp/s"; rm -rf "$tmp"Expected result
Alice,80
Bob,90Key points
- paste joins lines
- -d sets the delimiter
- join matches keys
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.