No such thing as a small change | |
PerlMonks |
Re^2: Remove Duplicate Linesby afoken (Chancellor) |
on Aug 01, 2019 at 19:47 UTC ( [id://11103725]=note: print w/replies, xml ) | Need Help?? |
Let's see:
This is highly inefficient and has several issues with "interesting" filenames. In Re: Remove Duplicate Lines, BrowserUk explains how to use perl properly. Another option - if running on a POSIX compatible system - is to use sort properly. Without headers, it is trivial:
With headers, this will do:
This way, head can stop processing the input file after the first line, unlike sed -n '1p'. Directly writing to the outputfile avoids all further overhead of your script. Alexander (1) yes, given a sane filename, perl may start the first sed without help of the default shell. Change the filename to something interesting and perl will start sed via the default shell.
-- Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)
In Section
Seekers of Perl Wisdom
|
|