<?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: grep problem - matching 2 different patterns in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/grep-problem-matching-2-different-patterns/m-p/3635465#M238337</link>
    <description>You can use awk or sed as well as. &lt;BR /&gt;&lt;BR /&gt;# sed -n '/flowNextHop/p;/flowTargetPort/p;/flowSourcePort/p'  &lt;FILENAME&gt; | wc -l&lt;BR /&gt;&lt;BR /&gt;or&lt;BR /&gt;&lt;BR /&gt;# awk '/flowTargetPort/ /flowSourcePort/ /flowNextHop/ { print; }' &lt;FILENAME&gt; | wc -l&lt;BR /&gt;&lt;BR /&gt;hth.&lt;/FILENAME&gt;&lt;/FILENAME&gt;</description>
    <pubDate>Tue, 27 Sep 2005 02:30:43 GMT</pubDate>
    <dc:creator>Muthukumar_5</dc:creator>
    <dc:date>2005-09-27T02:30:43Z</dc:date>
    <item>
      <title>grep problem - matching 2 different patterns</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/grep-problem-matching-2-different-patterns/m-p/3635461#M238333</link>
      <description>Hi,&lt;BR /&gt;I'm attempting to "grep" 2 different patterns from a file. The patterns are:&lt;BR /&gt;1)flowTargetPort&lt;BR /&gt;2)flowSourcePort &lt;BR /&gt;3)flowNextHop &lt;BR /&gt;&lt;BR /&gt;The file containing the 3 patterns above has the format of:&lt;BR /&gt; flowRawRecord&lt;BR /&gt;  {&lt;BR /&gt;   index "0"&lt;BR /&gt;   flowType "CiscoV1"&lt;BR /&gt;   flowUptime "2662858776"&lt;BR /&gt;   flowSequence "8"&lt;BR /&gt;   flowTOS "0"&lt;BR /&gt;   flowTCPFlag "16"&lt;BR /&gt;   flowProtocolNumber "1"&lt;BR /&gt;   flowInputIfIndex "4"&lt;BR /&gt;   flowOutputIfIndex "1"&lt;BR /&gt;   flowNextHop "155.226.201.148"&lt;BR /&gt;   flowSourceIP "192.168.205.10"&lt;BR /&gt;   flowTargetIP "155.226.201.148"&lt;BR /&gt;   flowSourceName "192.168.205.10"&lt;BR /&gt;   flowTargetName "mola.metricauk.adc.com"&lt;BR /&gt;   flowSourcePort "0"&lt;BR /&gt;   flowTargetPort "771"&lt;BR /&gt;   flowPackets "2"&lt;BR /&gt;   flowOctets "162"&lt;BR /&gt;  }&lt;BR /&gt;&lt;BR /&gt;I've used technique shown below to obtain the first 2 patterns i.e. flowTargetPort and flowSourcePort:&lt;BR /&gt;bash-2.03$ cat EventCollector-evtCJLeaw.CJLeaw_26_09_2005_04_19_12.data |grep "flow.*Port \"123\"" |wc -l&lt;BR /&gt;     241&lt;BR /&gt; &lt;BR /&gt;However, it failed to return any number of records from the file when I attempted to match the 3rd pattern along with the 1st 2 patterns:&lt;BR /&gt;bash-2.03$ cat EventCollector-evtCJLeaw.CJLeaw_26_09_2005_04_19_12.data |grep "flow.*Port \"123\""|grep "flowNextHop" |wc -l&lt;BR /&gt;     0&lt;BR /&gt;&lt;BR /&gt;Could anyone show me how I could use "grep" to match 2 or more patterns simulataneously?&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;Danny</description>
      <pubDate>Tue, 27 Sep 2005 02:14:12 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/grep-problem-matching-2-different-patterns/m-p/3635461#M238333</guid>
      <dc:creator>Danny Fang</dc:creator>
      <dc:date>2005-09-27T02:14:12Z</dc:date>
    </item>
    <item>
      <title>Re: grep problem - matching 2 different patterns</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/grep-problem-matching-2-different-patterns/m-p/3635462#M238334</link>
      <description>You can use grep -E "pattern1|pattern2|..|patternn" or simply egrep "pattern1|pattern2|..|patternn"&lt;BR /&gt;&lt;BR /&gt;# Example's&lt;BR /&gt;# echo "hi\nbye" | grep -E 'hi|bye'&lt;BR /&gt;hi&lt;BR /&gt;bye&lt;BR /&gt;# echo "hi\nbye" | egrep 'hi|bye'&lt;BR /&gt;hi&lt;BR /&gt;bye&lt;BR /&gt;#&lt;BR /&gt;&lt;BR /&gt;hth.</description>
      <pubDate>Tue, 27 Sep 2005 02:22:05 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/grep-problem-matching-2-different-patterns/m-p/3635462#M238334</guid>
      <dc:creator>Muthukumar_5</dc:creator>
      <dc:date>2005-09-27T02:22:05Z</dc:date>
    </item>
    <item>
      <title>Re: grep problem - matching 2 different patterns</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/grep-problem-matching-2-different-patterns/m-p/3635463#M238335</link>
      <description>Use simply as,&lt;BR /&gt;&lt;BR /&gt;# grep -E 'flowTargetPort|flowSourcePort|flowNextHop' EventCollector-evtCJLeaw.CJLeaw_26_09_2005_04_19_12.data | wc -l&lt;BR /&gt;&lt;BR /&gt;or&lt;BR /&gt;&lt;BR /&gt;# egrep 'flowTargetPort|flowSourcePort|flowNextHop' EventCollector-evtCJLeaw.CJLeaw_26_09_2005_04_19_12.data | wc -l&lt;BR /&gt;&lt;BR /&gt;It will return all counts.&lt;BR /&gt;&lt;BR /&gt;P.S: Don't use cat &lt;FILE&gt; | grep operation. It is very slow. You can directly use as,&lt;BR /&gt;&lt;BR /&gt;grep &lt;PATTERN&gt; &lt;FILE&gt;&lt;BR /&gt;&lt;BR /&gt;or&lt;BR /&gt;&lt;BR /&gt;grep pattern &amp;lt; file&lt;BR /&gt;&lt;BR /&gt;hth.&lt;/FILE&gt;&lt;/PATTERN&gt;&lt;/FILE&gt;</description>
      <pubDate>Tue, 27 Sep 2005 02:24:51 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/grep-problem-matching-2-different-patterns/m-p/3635463#M238335</guid>
      <dc:creator>Muthukumar_5</dc:creator>
      <dc:date>2005-09-27T02:24:51Z</dc:date>
    </item>
    <item>
      <title>Re: grep problem - matching 2 different patterns</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/grep-problem-matching-2-different-patterns/m-p/3635464#M238336</link>
      <description>You can use egrep to match 2 or more patterns. &lt;BR /&gt;&lt;BR /&gt;-Arun</description>
      <pubDate>Tue, 27 Sep 2005 02:30:22 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/grep-problem-matching-2-different-patterns/m-p/3635464#M238336</guid>
      <dc:creator>Arunvijai_4</dc:creator>
      <dc:date>2005-09-27T02:30:22Z</dc:date>
    </item>
    <item>
      <title>Re: grep problem - matching 2 different patterns</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/grep-problem-matching-2-different-patterns/m-p/3635465#M238337</link>
      <description>You can use awk or sed as well as. &lt;BR /&gt;&lt;BR /&gt;# sed -n '/flowNextHop/p;/flowTargetPort/p;/flowSourcePort/p'  &lt;FILENAME&gt; | wc -l&lt;BR /&gt;&lt;BR /&gt;or&lt;BR /&gt;&lt;BR /&gt;# awk '/flowTargetPort/ /flowSourcePort/ /flowNextHop/ { print; }' &lt;FILENAME&gt; | wc -l&lt;BR /&gt;&lt;BR /&gt;hth.&lt;/FILENAME&gt;&lt;/FILENAME&gt;</description>
      <pubDate>Tue, 27 Sep 2005 02:30:43 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/grep-problem-matching-2-different-patterns/m-p/3635465#M238337</guid>
      <dc:creator>Muthukumar_5</dc:creator>
      <dc:date>2005-09-27T02:30:43Z</dc:date>
    </item>
    <item>
      <title>Re: grep problem - matching 2 different patterns</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/grep-problem-matching-2-different-patterns/m-p/3635466#M238338</link>
      <description>Hi Danny ,&lt;BR /&gt;&lt;BR /&gt;You can use like this :&lt;BR /&gt;&lt;BR /&gt;$ cat EventCollector-evtCJLeaw.CJLeaw_26_09_2005_04_19_12.data | grep  -e "flow.*Port \"123\"" -e   "flowNextHop" | wc -l&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Syntax: &lt;BR /&gt;$ cat filename | grep -e "Pattern1" -e "Pattern2"  -e "Pattern_n"  | wc -l&lt;BR /&gt;&lt;BR /&gt;Enjoy..&lt;BR /&gt;Cheers,&lt;BR /&gt;Raj.</description>
      <pubDate>Tue, 27 Sep 2005 04:05:18 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/grep-problem-matching-2-different-patterns/m-p/3635466#M238338</guid>
      <dc:creator>Raj D.</dc:creator>
      <dc:date>2005-09-27T04:05:18Z</dc:date>
    </item>
    <item>
      <title>Re: grep problem - matching 2 different patterns</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/grep-problem-matching-2-different-patterns/m-p/3635467#M238339</link>
      <description>As Muthukumar said, both "cat" and "grep" in a single script will cause performance issues. Try using "grep" directly with the above said options. &lt;BR /&gt;&lt;BR /&gt;-Arun</description>
      <pubDate>Tue, 27 Sep 2005 04:11:18 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/grep-problem-matching-2-different-patterns/m-p/3635467#M238339</guid>
      <dc:creator>Arunvijai_4</dc:creator>
      <dc:date>2005-09-27T04:11:18Z</dc:date>
    </item>
    <item>
      <title>Re: grep problem - matching 2 different patterns</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/grep-problem-matching-2-different-patterns/m-p/3635468#M238340</link>
      <description>grep'ing for "flow.*Port \"123\"" won't match the "flowNextHop" pattern. You need to use egrep for that:&lt;BR /&gt;&lt;BR /&gt;# egrep -i "flowTargetPort|flowSourcePort|flowNextHop" EventCollector-evtCJLeaw.CJLeaw_26_09_2005_04_19_12.dat&lt;BR /&gt;&lt;BR /&gt;regards! &lt;BR /&gt;</description>
      <pubDate>Tue, 27 Sep 2005 05:17:54 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/grep-problem-matching-2-different-patterns/m-p/3635468#M238340</guid>
      <dc:creator>Sandman!</dc:creator>
      <dc:date>2005-09-27T05:17:54Z</dc:date>
    </item>
    <item>
      <title>Re: grep problem - matching 2 different patterns</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/grep-problem-matching-2-different-patterns/m-p/3635469#M238341</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;I attempted the awk method suggested by Muthukumar and I obtained the error below:&lt;BR /&gt;bash-2.03$ awk '/flowTargetPort/flowSourcePort/flowNextHop/ {print;}' EventCollector-evtCJLeaw.CJLeaw_26_09_2005_04_19_12.data &lt;BR /&gt;awk: syntax error near line 1&lt;BR /&gt;awk: bailing out near line 1&lt;BR /&gt;&lt;BR /&gt;May I know where did I go wrong?&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;Danny&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 27 Sep 2005 06:08:05 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/grep-problem-matching-2-different-patterns/m-p/3635469#M238341</guid>
      <dc:creator>Danny Fang</dc:creator>
      <dc:date>2005-09-27T06:08:05Z</dc:date>
    </item>
    <item>
      <title>Re: grep problem - matching 2 different patterns</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/grep-problem-matching-2-different-patterns/m-p/3635470#M238342</link>
      <description>It is the problem with your syntax:&lt;BR /&gt;&lt;BR /&gt;Use as:&lt;BR /&gt;&lt;BR /&gt;# awk '/flowTargetPort/ /flowSourcePort/ /flowNextHop/ {print;}' /tmp/datafile&lt;BR /&gt;flowNextHop "155.226.201.148"&lt;BR /&gt;flowSourcePort "0"&lt;BR /&gt;flowTargetPort "771"&lt;BR /&gt;&lt;BR /&gt;# Syntax&lt;BR /&gt;# awk '/pattern1/&lt;SPACE&gt;/pattern2/&lt;SPACE&gt;/pattern3&amp;gt;/ { print; }' &amp;lt; inputfile | wc -l&lt;BR /&gt;&lt;BR /&gt;hth.&lt;/SPACE&gt;&lt;/SPACE&gt;</description>
      <pubDate>Tue, 27 Sep 2005 06:15:48 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/grep-problem-matching-2-different-patterns/m-p/3635470#M238342</guid>
      <dc:creator>Muthukumar_5</dc:creator>
      <dc:date>2005-09-27T06:15:48Z</dc:date>
    </item>
    <item>
      <title>Re: grep problem - matching 2 different patterns</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/grep-problem-matching-2-different-patterns/m-p/3635471#M238343</link>
      <description>You can simply use perl also as,&lt;BR /&gt;&lt;BR /&gt;# perl -ne 'print if /flowTargetPort|flowSourcePort|flowNextHop/ ' EventCollector-evtCJLeaw.CJLeaw_26_09_2005_04_19_12.data&lt;BR /&gt;&lt;BR /&gt;where,&lt;BR /&gt;&lt;BR /&gt;/flowTargetPort|flowSourcePort|flowNextHop/ &lt;BR /&gt;&lt;BR /&gt;/ / -&amp;gt; checks for pattern(s).&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;hth.</description>
      <pubDate>Tue, 27 Sep 2005 06:17:52 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/grep-problem-matching-2-different-patterns/m-p/3635471#M238343</guid>
      <dc:creator>Muthukumar_5</dc:creator>
      <dc:date>2005-09-27T06:17:52Z</dc:date>
    </item>
    <item>
      <title>Re: grep problem - matching 2 different patterns</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/grep-problem-matching-2-different-patterns/m-p/3635472#M238344</link>
      <description>Hi, &lt;BR /&gt;&lt;BR /&gt;If I'd want to include the complete/exact pattern match of the patterns below:&lt;BR /&gt;flowSourcePort "0"&lt;BR /&gt;flowTargetPort "771"&lt;BR /&gt;&lt;BR /&gt;Could anyone, show me how it's done with both sed and awk? &lt;BR /&gt;&lt;BR /&gt;I've tried using the sed and awk methods below but they did not seem to work.&lt;BR /&gt;&lt;BR /&gt;Usage 1:&lt;BR /&gt;bash-2.03$ sed '/flowTargetPort \"123\"/flowSourcePort \"123\"/flowNextHop \"0.0.0.0\/" {print}' EventCollector-evtTest.Test_26_09_2005_04_19_12.data&lt;BR /&gt;Unrecognized command: /flowTargetPort \"123\"/flowSourcePort \"123\"/flowNextHop \"0.0.0.0\/" {print}&lt;BR /&gt;&lt;BR /&gt;Usage 2:&lt;BR /&gt;bash-2.03$ awk '/flowTargetPort \"123\"/flowSourcePort \"123\"/flowNextHop \"0.0.0.0\/" {print}' EventCollector-evtTest.Test_26_09_2005_04_19_12.data&lt;BR /&gt;awk: syntax error near line 1&lt;BR /&gt;awk: bailing out near line 1&lt;BR /&gt;&lt;BR /&gt;Usage 3:&lt;BR /&gt;bash-2.03$ awk '/flowTargetPort \"123\"/ /flowSourcePort \"123\"/ /flowNextHop \"0.0.0.0\/" {print}' EventCollector-evtTest.Test_26_09_2005_04_19_12.data&lt;BR /&gt;awk: syntax error near line 1&lt;BR /&gt;awk: bailing out near line 1&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;Danny</description>
      <pubDate>Tue, 27 Sep 2005 06:30:42 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/grep-problem-matching-2-different-patterns/m-p/3635472#M238344</guid>
      <dc:creator>Danny Fang</dc:creator>
      <dc:date>2005-09-27T06:30:42Z</dc:date>
    </item>
    <item>
      <title>Re: grep problem - matching 2 different patterns</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/grep-problem-matching-2-different-patterns/m-p/3635473#M238345</link>
      <description>Why you are missing /&lt;SPACE&gt; between patterns in awk??&lt;BR /&gt;&lt;BR /&gt;# No need to negate " with \ also.&lt;BR /&gt;&lt;BR /&gt;Use like,&lt;BR /&gt;&lt;BR /&gt;awk '/flowTargetPort "123"/ /flowSourcePort "123"/ /flowNextHop "0.0.0.0"/ {print}' &lt;FILENAME&gt;&lt;BR /&gt;&lt;BR /&gt;# Example:&lt;BR /&gt;# echo 'flowNextHop "0.0.0.0"' | awk '/flowTargetPort "123"/ /flowSourcePort "123"/ /flowNextHop "0.0.0.0"/ {print}'&lt;BR /&gt;flowNextHop "0.0.0.0"&lt;BR /&gt;&lt;BR /&gt;hth.&lt;/FILENAME&gt;&lt;/SPACE&gt;</description>
      <pubDate>Tue, 27 Sep 2005 06:35:01 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/grep-problem-matching-2-different-patterns/m-p/3635473#M238345</guid>
      <dc:creator>Muthukumar_5</dc:creator>
      <dc:date>2005-09-27T06:35:01Z</dc:date>
    </item>
    <item>
      <title>Re: grep problem - matching 2 different patterns</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/grep-problem-matching-2-different-patterns/m-p/3635474#M238346</link>
      <description>And why you are using sed with awk syntax?? &lt;BR /&gt;&lt;BR /&gt;# Try with sed as,&lt;BR /&gt;#  sed -n '/flowTargetPort "123"/p;/flowSourcePort "123"/p;/flowNextHop "0.0.0.0"/p' &lt;FILENAME&gt;&lt;BR /&gt;&lt;BR /&gt;# Example:&lt;BR /&gt;# echo 'flowNextHop "0.0.0.0"' | sed -n '/flowTargetPort "123"/p;/flowSourcePort "123"/p;/flowNextHop "0.0.0.0"/p'&lt;BR /&gt;flowNextHop "0.0.0.0"&lt;BR /&gt;&lt;BR /&gt;With perl use as,&lt;BR /&gt;perl -ne 'print if /flowTargetPort "123"|flowSourcePort "123"|flowNextHop "0.0.0.0"/' &lt;FILENAME&gt;&lt;BR /&gt;&lt;BR /&gt;# Example:&lt;BR /&gt;# echo 'flowNextHop "0.0.0.0"' | perl -ne 'print if /flowTargetPort "123"|flowSourcePort "123"|flowNextHop "0.0.0.0"/'&lt;BR /&gt;flowNextHop "0.0.0.0"&lt;BR /&gt;#&lt;BR /&gt;&lt;BR /&gt;PS: Change your file of EventCollector-evtCJLeaw.CJLeaw_26_09_2005_04_19_12.data to some simple name as test.log for testing.&lt;BR /&gt;&lt;BR /&gt;# simply,&lt;BR /&gt;cp EventCollector-evtCJLeaw.CJLeaw_26_09_2005_04_19_12.data /tmp/datafile&lt;BR /&gt;&lt;BR /&gt;It is enough for testing ;)&lt;BR /&gt;&lt;BR /&gt;hth.&lt;BR /&gt;&lt;/FILENAME&gt;&lt;/FILENAME&gt;</description>
      <pubDate>Tue, 27 Sep 2005 06:38:17 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/grep-problem-matching-2-different-patterns/m-p/3635474#M238346</guid>
      <dc:creator>Muthukumar_5</dc:creator>
      <dc:date>2005-09-27T06:38:17Z</dc:date>
    </item>
    <item>
      <title>Re: grep problem - matching 2 different patterns</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/grep-problem-matching-2-different-patterns/m-p/3635475#M238347</link>
      <description>&lt;BR /&gt;&lt;BR /&gt;Danny,&lt;BR /&gt;&lt;BR /&gt;Once you spot those targets, what do you want to do with them?&lt;BR /&gt;My guess is that IF you see certain condition THEN you want to print something else that is not part of the conditions.&lt;BR /&gt;&lt;BR /&gt;I would approach that by setting flags for each condition spotted and then examine all flag when the 'end' of a group, or the last condition is spotted.&lt;BR /&gt;In a perl script this would look like:&lt;BR /&gt;&lt;BR /&gt;--- filter.pl ----&lt;BR /&gt;$nh=$_ if /^flowNextHop/;&lt;BR /&gt;$sp=$1 if /^flowSourcePort\s+"(.*)"/;&lt;BR /&gt;$tp=$1 if  /^flowTargetPort\s+"(.*)"/;&lt;BR /&gt;print $nh if (/^}$/ &amp;amp;&amp;amp; $sp==0 &amp;amp;&amp;amp; $tp==771);&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Usage: perl -n filter.pl your-data&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Next I suspect that you are not done with just the test/filters mentioned.&lt;BR /&gt;I would suggest to generalize that.&lt;BR /&gt;For example&lt;BR /&gt;&lt;BR /&gt;---- general-filter.pl -----&lt;BR /&gt;&lt;BR /&gt;$val{$1}=$2 if (/^(\w+)\s*"(.*)"/);&lt;BR /&gt;if (/^}$/) {&lt;BR /&gt;  print $val{flowNextHop}."\n" if &lt;BR /&gt;   ($val{flowSourcePort} == 0&lt;BR /&gt;   &amp;amp;&amp;amp; $val{flowTargetPort}==771);&lt;BR /&gt; }&lt;BR /&gt;&lt;BR /&gt;Usage: perl -n filter.pl your-data&lt;BR /&gt;&lt;BR /&gt;That first line takes anything that vaguely looks like:  &lt;BR /&gt;&lt;START-OF-LINE&gt;&lt;BR /&gt;&lt;WORD&gt;&lt;BR /&gt;&lt;SOME-OR-NONE-WHITESPACE&gt;&lt;BR /&gt;&lt;QUOTE&gt;&lt;BR /&gt;&lt;SOME text=""&gt;&lt;BR /&gt;&lt;QUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;If it sees that, it assigns an array element called 'word; to become 'some text'.&lt;BR /&gt;For each line.&lt;BR /&gt;&lt;BR /&gt;Now when it see a closing curly on its own it si time to evaluate what has been gathered:&lt;BR /&gt;test specific value and print whatever is needed!&lt;BR /&gt;&lt;BR /&gt;hth,&lt;BR /&gt;Hein.&lt;BR /&gt;&lt;BR /&gt;&lt;/QUOTE&gt;&lt;/SOME&gt;&lt;/QUOTE&gt;&lt;/SOME-OR-NONE-WHITESPACE&gt;&lt;/WORD&gt;&lt;/START-OF-LINE&gt;</description>
      <pubDate>Tue, 27 Sep 2005 10:06:28 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/grep-problem-matching-2-different-patterns/m-p/3635475#M238347</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2005-09-27T10:06:28Z</dc:date>
    </item>
    <item>
      <title>Re: grep problem - matching 2 different patterns</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/grep-problem-matching-2-different-patterns/m-p/3635476#M238348</link>
      <description>Try the following awk construct:&lt;BR /&gt;&lt;BR /&gt;# awk '&lt;BR /&gt;&amp;gt; /^flowTargetPort/&lt;BR /&gt;&amp;gt; /^flowSourcePort/&lt;BR /&gt;&amp;gt; /^flowNextHop/&lt;BR /&gt;&amp;gt; ' your_input_file</description>
      <pubDate>Tue, 27 Sep 2005 13:50:38 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/grep-problem-matching-2-different-patterns/m-p/3635476#M238348</guid>
      <dc:creator>Sandman!</dc:creator>
      <dc:date>2005-09-27T13:50:38Z</dc:date>
    </item>
    <item>
      <title>Re: grep problem - matching 2 different patterns</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/grep-problem-matching-2-different-patterns/m-p/3635477#M238349</link>
      <description>Hi Danny,&lt;BR /&gt;&lt;BR /&gt;Use grep as follows:&lt;BR /&gt;&lt;BR /&gt;grep -e "pattern one" -e "pattern two" source_file&lt;BR /&gt;&lt;BR /&gt;Rgds,&lt;BR /&gt;Jeff</description>
      <pubDate>Tue, 27 Sep 2005 14:01:15 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/grep-problem-matching-2-different-patterns/m-p/3635477#M238349</guid>
      <dc:creator>Jeff Schussele</dc:creator>
      <dc:date>2005-09-27T14:01:15Z</dc:date>
    </item>
    <item>
      <title>Re: grep problem - matching 2 different patterns</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/grep-problem-matching-2-different-patterns/m-p/3635478#M238350</link>
      <description>If I read this correctly you not only want to get the pattern but also ONLY the pattern (that is to say you don't what the rest of the same line the pattern appears on).  If so you combine awk and grep:&lt;BR /&gt;&lt;BR /&gt;grep -E "flowTargetPort|flowSourcePort|flowNextHop" |awk '{print $1}'&lt;BR /&gt;&lt;BR /&gt;Note the above is all one line.&lt;BR /&gt;&lt;BR /&gt;The "grep -E" (a/k/a egrep) says to do a regexp grep.  The items in the quote are separated by a pipe sign which in regexp is used for "or" symbol.  &lt;BR /&gt;&lt;BR /&gt;You then pipe the grep -E output (pipe  now being used in its shell sense as a form of redirection) to the awk command.  &lt;BR /&gt;&lt;BR /&gt;awk by default uses white space (tabs and/or spaces) as the field delimiter).  Since the pattern you want is the first item on the line it is the first field so the print command is saying to display the first field.</description>
      <pubDate>Wed, 28 Sep 2005 08:45:25 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/grep-problem-matching-2-different-patterns/m-p/3635478#M238350</guid>
      <dc:creator>Jeff Lightner_1</dc:creator>
      <dc:date>2005-09-28T08:45:25Z</dc:date>
    </item>
  </channel>
</rss>

