Split records.txt into multiple files containing 1000 lines each.
Use part- as the output filename prefix.
Which command is appropriate?
split -l N INPUT PREFIX divides input into N-line files and adds suffixes to the chosen prefix.
Detailed explanation
split -b 1000 records.txt part-Incorrect. -b 1000 splits by bytes, not lines.
Incorrect. -b 1000 splits by bytes, not lines.
split -l 1000 records.txt part-Correct. split -l 1000 records.txt part- creates 1000-line parts.
Correct. split -l 1000 records.txt part- creates 1000-line parts.
head -n 1000 records.txt part-Incorrect. head displays the first lines and does not create a set of output files.
Incorrect. head displays the first lines and does not create a set of output files.
cut -l 1000 records.txt part-Incorrect. cut has no -l option for line-based file splitting.
Incorrect. cut has no -l option for line-based file splitting.
Try it yourself
An example you can run in a temporary verification environment.
tmp=$(mktemp -d); seq 1 5 >"$tmp/in"; split -l 2 "$tmp/in" "$tmp/part-"; wc -l "$tmp"/part-*; rm -rf "$tmp"Expected result
2行、2行、1行の3ファイルKey points
- -l means lines
- -b means bytes
- The prefix names output parts
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.