Operating System - HP-UX
1753776 Members
7107 Online
108799 Solutions
New Discussion

Remove consecutive duplicated lines from a file

 
SOLVED
Go to solution
gaudiobe
Advisor

Remove consecutive duplicated lines from a file

Hello,

I need an help in order to remove some duplicated lines from a text file.

######### INPUT FILE ###########

ABC

CDE

FGH

FGH

ABC

ABC

ABC

FGH

CDE

CDE

#####################################

 

DESIRED OUTPUT

######### OUTPUT FILE ###########

ABC

CDE

FGH

ABC

FGH

CDE

#####################################

I do not need to order the file. buto only to remove duplicated lines if they are consecutive.

Thanks in advance for your help.

 

Regards,

Bernardo

1 REPLY 1
Solution

Re: Remove consecutive duplicated lines from a file

not really a HP-UX sepcific question - there are lots of ways to do this and some simple google-fu would have found some...

This selection of answers was near the top of my search response:

https://stackoverflow.com/questions/1444406/how-to-delete-duplicate-lines-in-a-file-without-sorting-it-in-unix

 


I am an HPE Employee
Accept or Kudo