Splitting a file based on line number

Hi I have a file with over a million lines (rows) and I want to split everything from 500,000 to a million into another file (to make the file smaller). Is there a simple command for this?

Thank you

Phil

Take a look at split. E.g:

split -l 500000 infile
1 Like

Try:

split -dl500000 -a1 file file

This will create file0, file1, ..., each having 500000 lines or less.

1 Like

hi thanks but what would the output command be? what do i put after > or does it automatically produce an output?

Try the split command, ls the files to be created, and you will know the answer you just asked.