I'll answer both your posts in one:

Please show a sample.
Please show a sample.

Your sample data doesn't contain duplicates. This does:

10.35.15.64/29 10.133.3.11 OSPF-EXT1 3 if-servermgm +t.cntx03-servermgmt-10.133.3.11 10.35.15.96/28 10.133.3.11 OSPF-EXT1 3 if-servermgm +t.cntx03-servermgmt-10.133.3.11 10.35.2.128/25 10.133.3.11 OSPF-EXT1 3 if-servermgm +t.cntx03-servermgmt-10.133.3.11 10.35.24.192/26 10.133.3.11 OSPF-EXT1 3 if-servermgm +t.cntx03-servermgmt-10.133.3.11 10.35.24.48/28 10.133.3.11 OSPF-EXT1 3 if-servermgm +t.cntx03-servermgmt-10.133.3.11 10.35.25.128/25 10.133.3.11 OSPF-EXT1 3 if-servermgm +t.cntx03-servermgmt-10.133.3.11 10.35.25.32/28 10.133.3.11 OSPF-EXT1 3 if-servermgm +t.cntx03-servermgmt-10.133.3.11 10.35.25.48/28 10.133.3.11 OSPF-EXT1 3 if-servermgm +t.cntx03-servermgmt-10.133.3.11 10.35.25.64/28 10.133.3.11 OSPF-EXT1 3 if-servermgm +t.cntx03-servermgmt-10.133.3.11 10.35.25.80/28 10.133.3.11 OSPF-EXT1 3 if-servermgm +t.cntx03-servermgmt-10.133.3.11 10.35.26.0/28 10.133.3.11 OSPF-EXT1 3 if-servermgm +t.cntx03-servermgmt-10.133.3.11 10.35.25.32/28 10.133.3.11 OSPF-EXT1 3 if-illnevera +nswerquestionsagain-10.133.3.11 10.35.26.16/28 10.133.3.11 OSPF-EXT1 3 if-servermgm +t.cntx03-servermgmt-10.133.3.11 10.35.26.192/26 10.133.3.11 OSPF-EXT1 3 if-servermgm +t.cntx03-servermgmt-10.133.3.11 10.35.26.32/27 10.133.3.11 OSPF-EXT1 3 if-servermgm +t.cntx03-servermgmt-10.133.3.11 10.35.26.64/28 10.133.3.11 OSPF-EXT1 3 if-servermgm +t.cntx03-servermgmt-10.133.3.11 10.35.26.96/27 10.133.3.11 OSPF-EXT1 3 if-servermgm +t.cntx03-servermgmt-10.133.3.11 10.35.8.128/27 10.133.3.11 OSPF-EXT1 3 if-servermgm +t.cntx03-servermgmt-10.133.3.11 10.35.8.192/27 10.133.3.11 OSPF-EXT1 3 if-servermgm +t.cntx03-servermgmt-10.133.3.11 10.35.9.128/28 10.133.3.11 OSPF-EXT1 3 if-servermgm +t.cntx03-servermgmt-10.133.3.11

If I run my snippet unaltered, I get

10.35.25.32/28 10.133.3.11 OSPF-EXT1 3 if-servermgm +t.cntx03-servermgmt-10.133.3.11 10.35.25.32/28 10.133.3.11 OSPF-EXT1 3 if-illnevera +nswerquestionsagain-10.133.3.11

It outputs pairs: the previous and the current match. So if you have 3 lines starting with the same CIDR notated IP address, you'll get 4 lines back for that match. With 4 lines matching, you get 6 lines: 3 pairs.

<update>

perl -ne '/^(\S+)/;if($S{$1}){print$S{$1}unless$s{$1}++;print}$S{$1}=$ +_' file

outputs just 4 lines for 4 matches.

</update>

--shmem

_($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                              /\_¯/(q    /
----------------------------  \__(m.====·.(_("always off the crowd"))."·
");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}

In reply to Re^3: Searching for two lines that begin with the same string by shmem
in thread Searching for two lines that begin with the same string by tgrossner

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.