I have a file in which more than 50,000 lines are there. How can I split the file into two or more based on the selected lines?
Suppose I want to split a file from line 10,000 to line 40,000.
I have a file in which more than 50,000 lines are there. How can I split the file into two or more based on the selected lines?
Suppose I want to split a file from line 10,000 to line 40,000.
Use awk:
awk ' NR<=10000{ next}
NR<=40000{print > "out2.txt"; next} ' input.txt
If you want lines 1 to 9999 in one file, 10000 to 40000 in a second and the rest in a 3rd, you can use:
csplit -f file.out file.in 10000 40001
(will store in file.out0{0,1,2})
You can use sed:
sed -n '10000,40000p' <infile