Find the answer to your Linux question:
Results 1 to 2 of 2
Hello All, This is not an Ubuntu question, more like a command question but since I use Ubuntu I just jumped into this section. I am trying to sort a ...
  1. #1
    Just Joined!
    Join Date
    Dec 2009
    Posts
    1

    sed question.

    Hello All,

    This is not an Ubuntu question, more like a command question but since I use Ubuntu I just jumped into this section.

    I am trying to sort a text file and remove all the duplicates. Every single line within this file looks like this:

    zone "URLHERE"{ type master; file "named.bhd"; }; # malware/malwaredomains/malwaredomains 2009-12-02

    what I want to make sure that that the section that says "URLHERE" is unique for every occurrence. Everything else within this command line is unique other than the date.

    I tried using :sort -u in VI but this didn't remove all the duplicates since some were added in different days.

    I am pretty sure this can be done with sed, but I'm just not that familiar with it.

    If anyone can help me out I'd truly appreciate it, and thanks in advance!

  2. #2
    Just Joined!
    Join Date
    Dec 2009
    Location
    Highlands
    Posts
    37
    I'm no techie, but I'm fairly sure that a sed command processes each line in turn, one line at a time.

    So you cannot "hold" a line in memory to check if a later line matches that line.

    Have you tried "uniq"?

    uniq - Wikipedia, the free encyclopedia
    .

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...