Loading ...
Sorry, an error occurred while loading the content.

Re: Regex headache :)

Expand Messages
  • Jean-Raymond.Chauviere
    ... Not the answer to your question, ( I suppose pepe s one is good) but anyway you don t need awk sort -u +0 -1 can do the job, eventually redirected to the
    Message 1 of 3 , Dec 5, 2000
    • 0 Attachment
      Gregoire Welraeds wrote:
      >
      > Hello vimers,
      >
      > I have a file that is divided in 3 column. For selection purposes, the
      > only one that matters is the first one. Here is a small entry example:
      >
      > 2dehands 1D IN NS ns.vuurwerk.nl.
      > 2design4u 1D IN NS auth00.ns.be.uu.net.
      > 2ez 1D IN NS ns.belbone
      > 2ez 1D IN NS ns2.belbone
      > 2frame 1D IN NS ns0.be.easynet.net.
      > 2its 1D IN NS ns1.tbs
      > 2its 1D IN NS ns2.skynet
      > 2its 1D IN NS ns2.tbs
      > 2its 1D IN NS ns3.skynet
      > 2mb 1D IN NS ns1.skynet
      >
      > Now I could easily do a small awk script that delete a row if the name in
      > the first column is the same than the name in the above row (same column).
      >
      > example:
      >
      > 2its 1D IN NS ns1.tbs
      > 2its 1D IN NS ns2.skynet # <== delete this one
      >
      > I was wondering if there is some magical vim regular expression capable of
      > doing the same job. Not that I need to do it in vim. Generaly, I think
      > that we should use the right tool for a job. Vim is an editor, awk a
      > pattern processing language.

      Not the answer to your question, ( I suppose pepe's one is good)
      but anyway you don't need awk
      sort -u +0 -1
      can do the job, eventually redirected to the vim buffer :-)

      --
      Nur der Kleingeist hält Ordnung, das Genie beherrscht das Chaos.
      Seuls les petits esprits aiment l'ordre, le génie maitrîse le chaos.
      (anonyme)
    • Gregoire Welraeds
      On Wed, 6 Dec 2000, Jean-Raymond.Chauviere wrote: ... Yes, I could use sort. My awk script, if expanded, has only 4/5 lines... In the words, sort wins !
      Message 2 of 3 , Dec 7, 2000
      • 0 Attachment
        On Wed, 6 Dec 2000, Jean-Raymond.Chauviere wrote:

        <snip>

        > Not the answer to your question, ( I suppose pepe's one is good)
        > but anyway you don't need awk
        > sort -u +0 -1
        > can do the job, eventually redirected to the vim buffer :-)

        Yes, I could use sort. My awk script, if expanded, has only 4/5
        lines... In the words, sort wins ! :)

        Thank you guys for your answer. My curiosity has been satisfied 'till next
        time. I'm always amazed by the fact that there is almost a vim answer to
        every question :).

        Gregoire Welraeds
        Perceval Development Team!
        devel@...
        -------------------------------------------------------------------------------
        Perceval Technologies sa/nv Tel: +32-2-6409194
        Rue Tenbosch, 9 Fax: +32-2-6403154
        B-1000 Brussels general information: info@...
        BELGIUM technical information: helpdesk@...
        URL: http://www.perceval.be/
        -------------------------------------------------------------------------------
      • DouglasPotts@spectral-sys.com
        This is a little late as a suggestion, but I guess I thought someone else would come up with it as well. How about uniq ? It is in the GNU textutils
        Message 3 of 3 , Dec 7, 2000
        • 0 Attachment
          This is a little late as a suggestion, but I guess I thought someone
          else would come up with it as well. How about 'uniq'? It is in the
          GNU textutils package.

          - SOPHOCLES:/WINDOWS 201% uniq --help
          Usage: uniq [OPTION]... [INPUT [OUTPUT]]
          Discard all but one of successive identical lines from INPUT (or
          standard input), writing to OUTPUT (or standard output).

          -c, --count prefix lines by the number of occurrences
          -d, --repeated only print duplicate lines
          -f, --skip-fields=N avoid comparing the first N fields
          -i, --ignore-case ignore differences in case when comparing
          -s, --skip-chars=N avoid comparing the first N characters
          -u, --unique only print unique lines
          -w, --check-chars=N compare no more than N characters in lines
          -N same as -f N
          +N same as -s N
          --help display this help and exit
          --version output version information and exit

          A field is a run of whitespace, than non-whitespace characters.
          Fields are skipped before chars.

          Report bugs to textutils-bugs@...

          -Doug

          --
          *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
          Douglas L. Potts Spectral Systems, Inc. Url: http://www.bigfoot.com/~pottsdl
          "Writing is easy. It's all a matter of staring at a blank piece of paper
          until your forehead bleeds" -Douglas Adams
          *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*



          Gregoire
          Welraeds To: VIm Mailling list <vim@...>
          <greg@perceva cc:
          l.be> Subject: Re: Regex headache :)

          12/07/00
          08:50 AM





          On Wed, 6 Dec 2000, Jean-Raymond.Chauviere wrote:

          <snip>

          > Not the answer to your question, ( I suppose pepe's one is good)
          > but anyway you don't need awk
          > sort -u +0 -1
          > can do the job, eventually redirected to the vim buffer :-)

          Yes, I could use sort. My awk script, if expanded, has only 4/5
          lines... In the words, sort wins ! :)

          Thank you guys for your answer. My curiosity has been satisfied 'till next
          time. I'm always amazed by the fact that there is almost a vim answer to
          every question :).

          Gregoire Welraeds
          Perceval Development Team!
          devel@...
          -------------------------------------------------------------------------------

          Perceval Technologies sa/nv Tel: +32-2-6409194
          Rue Tenbosch, 9 Fax: +32-2-6403154

          B-1000 Brussels general information:
          info@...
          BELGIUM technical information:
          helpdesk@...
          URL: http://www.perceval.be/
          -------------------------------------------------------------------------------
        Your message has been successfully submitted and would be delivered to recipients shortly.