splitting a pipe delimited file in unix

Could one of you shad some light on this:

I need to split the file by determining the record count and than splitting it up into 4 files. Please note, this is not a fixed record length but rather a "|" delimited file.

I am not sure as how to handle reminder/offset for the 4th file.
For example:

"$1|wc -l" /4 + reminder

Please let me know. :rolleyes:

looking for split command

if not

please post sample input and output :slight_smile:

My file for ex. is a 10mil record file. Within the shell script I need to determine the record count and divided it into 4 separate files.

Is it ok to do a wc -l into a variable / 4? Would reminder take care of itself - meaning it will be a part of the 4th file.

Please advise and I hope this helps.

split -l $(( $( wc -l < filename ) / 4)) filename

thank you matrixmadhan. I will try this one first thing tomorrow morning.

Thank you again.