in reply to Re: split a file into number of file based on line count
in thread split a file into number of file based on line count

more specifically, to split into 5 ~equal files you can use the following construction in bash
split -l$(expr $(expr $(wc -l filename |cut -d\ -f1) / 5) + 1) filena +me

Replies are listed 'Best First'.
Re^3: split a file into number of file based on line count
by Bloodnok (Vicar) on May 13, 2009 at 10:02 UTC
    Why do all that when you can equally well use
    split -n 100 some_file
    ??

    See man split... (on some *NIXes, -l is used instead of -n to specify the line count)

    Update:

    Qualified the usage of the line count option

    A user level that continues to overstate my experience :-))
      Not general. See OP's ref to counting lines.
        Good point, well made ww :-D

        It's a classic case of me seeing what I wanted to - I saw ...split that file into 5 file each should contain 100 lines... and tho' I saw the subsequent narrative (fully defining the problem), I completely ignored it !!

        Glad it wasn't an exam :-D

        A user level that continues to overstate my experience :-))
Re^3: split a file into number of file based on line count
by JavaFan (Canon) on May 13, 2009 at 09:50 UTC
    That sounds like it can be golfed.
    split -l$((`cat filename|wc -l`/5+1)) filename