i am currently hitting with the insufficient memory issue when I run this command on my system.

With 12GB of memory and a 5GB file, this should not be happening.

When you hit an error, if you post the error message you receive -- cut&paste rather than paraphrased -- you may get a quick solution to your problem.

.By the way, can this command be used in script and run?

What kind of script?

or is it perl one liners?

It is a bog standard windows command.

It can be invoked: from the command line; from a batch script; from a perl script; or in any other way a system command can be invoked.

Also how is it different from external sort that I have used and now what you have mentioned?

The perl script you showed calls back into perl for every comparison; and (unnecessarially) re-splits two lines for every comparison.

Assuming your example snippet lines are representative of the whole file; and assuming average number of N*log2(N) comparisons are required to sort your file, that means you are calling back into Perl 1.5 billion times and re-spliting lines 3 billion times.

It is unsurprising that a dedicated sort utility that doesn't need to do either of those things will run more quickly.

Please clarify

You are sorting your data by the 1 field that appears at the beginning of each record, therefore there is no need to split the records in order to sort them correctly.


With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

The start of some sanity?


In reply to Re^3: external sort performance improved? by BrowserUk
in thread external sort performance improved? by rkshyam

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.