I have a txt file that I need to analyze for matching strings of numbers/text. (Its actually for looking for multiple routes in a routing table, but that shouldnt confuse the issue) So, for instance, I need to search through the file and find lines such as this:
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.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
and print out the lines that match before the first space:
10.1.17.0/24 10.133.3.11 OSPF-EXT2 20 if-servermgm +t.cntx03-servermgmt-10.133.3.11 10.1.17.0/24 10.133.3.7 OSPF-EXT2 20 if-servermgm +t.cntx03-servermgmt-10.133.3.7
I havent started writing my code, but I would be willing to bet someone knows a command line string of perl commands that will do this. Any thoughts?

In reply to 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.