2

Here an example of what my sh output look like

abc
abc
abc
rty // uio
rty // uio
fgh
fgh jkl
...

What I want in my output is

abc
abc
abc
rty // uio
fgh
fgh jkl
...

I would like to remove just one of the double lines with //. All duplicated lines (with // or not) are following each other.

I can't find something with cut, awk, sed, or even sort -u and uniq.

Charles Duffy
  • 280,126
  • 43
  • 390
  • 441
A D
  • 25
  • 6

1 Answers1

3

There is probably a simpler way of doing it, but here is a start with awk:

$ awk '!/\/\// || /\/\// && !seen[$0]++' file
abc
abc
abc
rty // uio
fgh
fgh jkl
...
user000001
  • 32,226
  • 12
  • 81
  • 108
  • Note the bullet point regarding questions which "*have already been asked and answered many times before*" in the "Answer Well-Asked Questions" section of [How to Answer](https://stackoverflow.com/help/how-to-answer). – Charles Duffy Sep 15 '18 at 16:05
  • @CharlesDuffy read the question carefully it's not a duplicate of the ones you linked. – user000001 Sep 15 '18 at 16:12
  • Title edited to make the distinguishing elements explicit. As this was originally asked, it would have been an "attractive nuisance" in the knowledgebase, getting attention from people who needed the more general-purpose answer since one had to click through to understand the distinction. – Charles Duffy Sep 15 '18 at 16:14