Need help splitting file

I have a file with 58,000 lines
How can I easily split this file into 5 files with 10,000 lines and then the 6th with 8,000.

I need to do this for multiple files with different number of lines but they all need to be split to have 10,000 lines max.

Someone suggested using the split command but from what I understand that will overwrite my currnet file and just create a file with how many lines I specify - which seems would not work since if I used:
split 10,000 input file outputfile

and it overwrites my original, if I make a copy then run it again how does it know to take the next 10,000?

Any help would be appreciated. Thank you in advance.

Hi

awk '{print > "f"(NR%10000?i:i++)}' i=1 file

You will have your files created like f1, f2,f3,...

Guru.

try the following with split command

split -l10 a ff

where
-l10 ==> number of lines to be splitted
a ==> file which has to be splitted
ff ==> new file name which will be suffixed as ffa, ffb,......

The script can split multiple files, and will not overwrite your original files.

for file in `ls *`
do
  awk '{print > FILENAME "_" (NR%10000?i:i++)}' i=1 $file
done

Maybe so?

$ x=0
$ y=1
$ for z in 10001 20001 30001 40001 50001 60001; do
awk "NR>$x&&NR<$z" file > file-p$y
x=$(($x+10000))
y=$(($y+1))
done