I know we can use > to redirect IO to a file. While I want to write fixed line to a file.
For example,
more something will output 3210 lines, then I want
line 1~1000 in file1
line 1001~2000 in file2
line 2001~3000 in file3
line 3001~3210 in file4.
How can I do it with SHELL script?
Thx.
The
splitcommand is what you need.Where:
-l- split in lines.1000- The number of lines to split.your_file.txt- The file you want to split.prefix- A prefix to the output files' names.Example for a file of 3210 lines: