Hi, I have a file sample_1.txt (300k rows) which has data like below: * Also each record is around 64k bytes
11|1|abc|102553|125589|64k bytes of data 10|2|def|123452|123356|...... 13|2|geh|144351|121123|... 25|4|fgh|165250|118890|.. 14|1|abc|186149|116657|...... 21|7|def|207048|114424|...... 23|7|geh|227947|112191|...... 26|32|fgh|248846|109958|...... 27|23|abc|269745|107725|...... 29|34|def|290644|105492|...... 30|32|geh|311543|103259|...... 33|23|fgh|332442|101026|...... 35|34|abc|353341|98793|...... 37|7|def|374240|96560|...... 39|4|geh|395139|94327|...... 41|2|fgh|416038|92094|...... 44|23|abc|436937|89861|...... 46|1|def|457836|87628|...... 48|3|geh|478735|85395|...... 50|23|fgh|499634|83162|......
I am trying to split the files based on the 2nd column like below sample_1_1.txt
11|1|abc|102553|125589|...... 14|1|abc|186149|116657|...... 46|1|def|457836|87628|......
sample_1_2.txt
10|2|def|123452|123356|...... 13|2|geh|144351|121123|...... 41|2|fgh|416038|92094|......
sample_1_3.txt
48|3|geh|478735|85395|......
and so on Could some help me on this. Thanks in advance

In reply to Split a file based on column by brad_nov

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.