perl - remove duplicate lines in a txt document and keep one? -
i not programmer, remove duplicate lines in document , keep original lines. trying text processors, editpadpro, since file more 1 gigabyte, gets frozen , can't complete operation.
i know perl @ this, don't know how use it, keeping in mind file can on 1 or 2 gb.
example of input lines:
line 1 line 2 line 3 line 1 line 2 line 4 line 1
example of output lines:
line 1 line 2 line 3 line 4
i sorry if basic, don't know how proceed, of time use built in functions, hope not annoy question.
if don't mind lines not being in original order, can use command:
$ sort -u old_file.txt > new_file.txt
the sort
sort file, , -u
option stands unique means output first matching line.
even large files, sort
may best hope.
Comments
Post a Comment