<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Search Pattern question in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/search-pattern-question/m-p/2692848#M842897</link>
    <description>Simple and effective onliner:&lt;BR /&gt;&lt;BR /&gt;awk '{if ($0!="Dest"){ prev=$0 } else printf "%s,%s\n",prev,$0; }' inputfile&lt;BR /&gt;&lt;BR /&gt;It gives:&lt;BR /&gt;15,Dest&lt;BR /&gt;66,Dest&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Ceesjan&lt;BR /&gt;&lt;BR /&gt;</description>
    <pubDate>Fri, 29 Mar 2002 11:16:39 GMT</pubDate>
    <dc:creator>Ceesjan van Hattum</dc:creator>
    <dc:date>2002-03-29T11:16:39Z</dc:date>
    <item>
      <title>Search Pattern question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/search-pattern-question/m-p/2692837#M842886</link>
      <description>Hello experts,&lt;BR /&gt;&lt;BR /&gt;I have a file like this :&lt;BR /&gt;12&lt;BR /&gt;13&lt;BR /&gt;15 &lt;BR /&gt;Dest&lt;BR /&gt;17&lt;BR /&gt;.&lt;BR /&gt;.&lt;BR /&gt;66&lt;BR /&gt;Dest&lt;BR /&gt;88&lt;BR /&gt;How do I extract/search the word Dest as well as the previous number say for example 15,Dest like that 66,Dest?.</description>
      <pubDate>Thu, 28 Mar 2002 15:51:29 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/search-pattern-question/m-p/2692837#M842886</guid>
      <dc:creator>Vasudevan MV</dc:creator>
      <dc:date>2002-03-28T15:51:29Z</dc:date>
    </item>
    <item>
      <title>Re: Search Pattern question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/search-pattern-question/m-p/2692838#M842887</link>
      <description>Press Esc :/Dest&lt;BR /&gt;&lt;BR /&gt;Sandip</description>
      <pubDate>Thu, 28 Mar 2002 16:00:37 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/search-pattern-question/m-p/2692838#M842887</guid>
      <dc:creator>Sandip Ghosh</dc:creator>
      <dc:date>2002-03-28T16:00:37Z</dc:date>
    </item>
    <item>
      <title>Re: Search Pattern question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/search-pattern-question/m-p/2692839#M842888</link>
      <description>Here is one simple awk method:&lt;BR /&gt;&lt;BR /&gt;Create an awk file, e.g. my.awk&lt;BR /&gt;------------&lt;BR /&gt;BEGIN {&lt;BR /&gt;  prev = ""&lt;BR /&gt;}&lt;BR /&gt;{&lt;BR /&gt;  if ($0 ~ /Dest/)&lt;BR /&gt;    {&lt;BR /&gt;      printf("%s,%s\n",prev,$0)&lt;BR /&gt;      prev = ""&lt;BR /&gt;    }&lt;BR /&gt;  else prev = $0&lt;BR /&gt;}&lt;BR /&gt;------------&lt;BR /&gt;&lt;BR /&gt;Then cat yourfile | awk -f my.awk &amp;gt; outfile&lt;BR /&gt;</description>
      <pubDate>Thu, 28 Mar 2002 16:01:07 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/search-pattern-question/m-p/2692839#M842888</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2002-03-28T16:01:07Z</dc:date>
    </item>
    <item>
      <title>Re: Search Pattern question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/search-pattern-question/m-p/2692840#M842889</link>
      <description># perl -ne 'BEGIN{$/="Dest\n"}s,.*\b(\d+)\n(?=$/),$1 ,s&amp;amp;&amp;amp;print' infile&lt;BR /&gt;15 Dest&lt;BR /&gt;66 Dest&lt;BR /&gt;#</description>
      <pubDate>Thu, 28 Mar 2002 16:27:50 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/search-pattern-question/m-p/2692840#M842889</guid>
      <dc:creator>H.Merijn Brand (procura</dc:creator>
      <dc:date>2002-03-28T16:27:50Z</dc:date>
    </item>
    <item>
      <title>Re: Search Pattern question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/search-pattern-question/m-p/2692841#M842890</link>
      <description>Hello all,&lt;BR /&gt;&lt;BR /&gt;Thanks for everyone, Clay's solution worked well and I have already written a shell script for this but I thought there should be some simple command to search multi pattern. Is there any other command or options in grep? &lt;BR /&gt;&lt;BR /&gt;I haven't installed perl on my box.&lt;BR /&gt;&lt;BR /&gt;Thanks &lt;BR /&gt;Vasu</description>
      <pubDate>Fri, 29 Mar 2002 09:09:29 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/search-pattern-question/m-p/2692841#M842890</guid>
      <dc:creator>Vasudevan MV</dc:creator>
      <dc:date>2002-03-29T09:09:29Z</dc:date>
    </item>
    <item>
      <title>Re: Search Pattern question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/search-pattern-question/m-p/2692842#M842891</link>
      <description>&lt;A href="http://hpux.cs.utah.edu/hppd/hpux/Languages/perl-5.6.1/" target="_blank"&gt;http://hpux.cs.utah.edu/hppd/hpux/Languages/perl-5.6.1/&lt;/A&gt; &lt;BR /&gt;&lt;BR /&gt;When you get used to perl, you can forget all about grep, awk, sed, sh, ...&lt;BR /&gt;&lt;BR /&gt;Well, you /could/, but you shouldn't :) There's a good tool for every problem, it only happens that perl fits to most problems</description>
      <pubDate>Fri, 29 Mar 2002 09:22:07 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/search-pattern-question/m-p/2692842#M842891</guid>
      <dc:creator>H.Merijn Brand (procura</dc:creator>
      <dc:date>2002-03-29T09:22:07Z</dc:date>
    </item>
    <item>
      <title>Re: Search Pattern question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/search-pattern-question/m-p/2692843#M842892</link>
      <description>Attached is a small executable called ngrep to do just this. It's in C, so you cant modify it - but you can use a wrapper script to customise the output to your needs.&lt;BR /&gt;The usage is as follows:&lt;BR /&gt;ngrep -n 1 -p Dest -f &lt;YOURFILE&gt;&lt;BR /&gt;where &lt;BR /&gt;-n 1 : get the matching line and 1 line before it&lt;BR /&gt;-p Dest : search pattern is "Dest"&lt;BR /&gt;-f : filename in which to search.&lt;BR /&gt;&lt;BR /&gt;&lt;/YOURFILE&gt;</description>
      <pubDate>Fri, 29 Mar 2002 09:31:44 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/search-pattern-question/m-p/2692843#M842892</guid>
      <dc:creator>Deepak Extross</dc:creator>
      <dc:date>2002-03-29T09:31:44Z</dc:date>
    </item>
    <item>
      <title>Re: Search Pattern question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/search-pattern-question/m-p/2692844#M842893</link>
      <description>Attaching again - this time in Winzip format.&lt;BR /&gt;Seems like there was a problem with the last attachment.</description>
      <pubDate>Fri, 29 Mar 2002 09:42:54 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/search-pattern-question/m-p/2692844#M842893</guid>
      <dc:creator>Deepak Extross</dc:creator>
      <dc:date>2002-03-29T09:42:54Z</dc:date>
    </item>
    <item>
      <title>Re: Search Pattern question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/search-pattern-question/m-p/2692845#M842894</link>
      <description>That's all standard in GNU grep, even colourizing the matched pattern:&lt;BR /&gt;&lt;BR /&gt;Context control:&lt;BR /&gt;  -B, --before-context=NUM  print NUM lines of leading context&lt;BR /&gt;  -A, --after-context=NUM   print NUM lines of trailing context&lt;BR /&gt;  -C, --context=NUM         print NUM lines of output context&lt;BR /&gt;  -NUM                      same as --context=NUM&lt;BR /&gt;      --color[=WHEN],&lt;BR /&gt;      --colour[=WHEN]       use markers to distinguish the matching string&lt;BR /&gt;                            WHEN may be `always', `never' or `auto'.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 29 Mar 2002 10:18:42 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/search-pattern-question/m-p/2692845#M842894</guid>
      <dc:creator>H.Merijn Brand (procura</dc:creator>
      <dc:date>2002-03-29T10:18:42Z</dc:date>
    </item>
    <item>
      <title>Re: Search Pattern question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/search-pattern-question/m-p/2692846#M842895</link>
      <description>Deepak,&lt;BR /&gt;&lt;BR /&gt;Thanks for ur response, but the executable is not running on my box.  I think some compatibility problem&lt;BR /&gt;&lt;BR /&gt;ERROR:&lt;BR /&gt;/usr/lib/dld.sl: Can't open shared library: /usr/lib/libc.2&lt;BR /&gt;/usr/lib/dld.sl: No such file or directory&lt;BR /&gt;Abort(coredump)&lt;BR /&gt;&lt;BR /&gt;Vasu&lt;BR /&gt;</description>
      <pubDate>Fri, 29 Mar 2002 10:26:54 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/search-pattern-question/m-p/2692846#M842895</guid>
      <dc:creator>Vasudevan MV</dc:creator>
      <dc:date>2002-03-29T10:26:54Z</dc:date>
    </item>
    <item>
      <title>Re: Search Pattern question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/search-pattern-question/m-p/2692847#M842896</link>
      <description>Ahhhrgg. 10.20 maybe?&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://hpux.tn.tudelft.nl/hppd/cgi-bin/redirect?hpux/Languages/perl-5.6.1/perl-5.6.1-sd-10.20.depot.gz" target="_blank"&gt;http://hpux.tn.tudelft.nl/hppd/cgi-bin/redirect?hpux/Languages/perl-5.6.1/perl-5.6.1-sd-10.20.depot.gz&lt;/A&gt;</description>
      <pubDate>Fri, 29 Mar 2002 10:30:50 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/search-pattern-question/m-p/2692847#M842896</guid>
      <dc:creator>H.Merijn Brand (procura</dc:creator>
      <dc:date>2002-03-29T10:30:50Z</dc:date>
    </item>
    <item>
      <title>Re: Search Pattern question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/search-pattern-question/m-p/2692848#M842897</link>
      <description>Simple and effective onliner:&lt;BR /&gt;&lt;BR /&gt;awk '{if ($0!="Dest"){ prev=$0 } else printf "%s,%s\n",prev,$0; }' inputfile&lt;BR /&gt;&lt;BR /&gt;It gives:&lt;BR /&gt;15,Dest&lt;BR /&gt;66,Dest&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Ceesjan&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 29 Mar 2002 11:16:39 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/search-pattern-question/m-p/2692848#M842897</guid>
      <dc:creator>Ceesjan van Hattum</dc:creator>
      <dc:date>2002-03-29T11:16:39Z</dc:date>
    </item>
  </channel>
</rss>

