<?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 egrep and patterns in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/egrep-and-patterns/m-p/4434052#M36868</link>
    <description>Hi&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;I know to use egrep like this for the OR&lt;BR /&gt;egrep -i '(65535|65536)'&lt;BR /&gt;&lt;BR /&gt;How to do the same thing but with AND &lt;BR /&gt;&lt;BR /&gt;Any Idea&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Bests Regards&lt;BR /&gt;Den</description>
    <pubDate>Fri, 05 Jun 2009 17:13:28 GMT</pubDate>
    <dc:creator>Leo The Cat</dc:creator>
    <dc:date>2009-06-05T17:13:28Z</dc:date>
    <item>
      <title>egrep and patterns</title>
      <link>https://community.hpe.com/t5/operating-system-linux/egrep-and-patterns/m-p/4434052#M36868</link>
      <description>Hi&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;I know to use egrep like this for the OR&lt;BR /&gt;egrep -i '(65535|65536)'&lt;BR /&gt;&lt;BR /&gt;How to do the same thing but with AND &lt;BR /&gt;&lt;BR /&gt;Any Idea&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Bests Regards&lt;BR /&gt;Den</description>
      <pubDate>Fri, 05 Jun 2009 17:13:28 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/egrep-and-patterns/m-p/4434052#M36868</guid>
      <dc:creator>Leo The Cat</dc:creator>
      <dc:date>2009-06-05T17:13:28Z</dc:date>
    </item>
    <item>
      <title>Re: egrep and patterns</title>
      <link>https://community.hpe.com/t5/operating-system-linux/egrep-and-patterns/m-p/4434053#M36869</link>
      <description>Ho sorry&lt;BR /&gt;&lt;BR /&gt;precision: patterns are not in the same line !&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 05 Jun 2009 17:24:47 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/egrep-and-patterns/m-p/4434053#M36869</guid>
      <dc:creator>Leo The Cat</dc:creator>
      <dc:date>2009-06-05T17:24:47Z</dc:date>
    </item>
    <item>
      <title>Re: egrep and patterns</title>
      <link>https://community.hpe.com/t5/operating-system-linux/egrep-and-patterns/m-p/4434054#M36870</link>
      <description>Here my input&lt;BR /&gt;a&lt;BR /&gt;b&lt;BR /&gt;c&lt;BR /&gt;d&lt;BR /&gt;e&lt;BR /&gt;test1&lt;BR /&gt;f&lt;BR /&gt;g&lt;BR /&gt;f&lt;BR /&gt;test2&lt;BR /&gt;h&lt;BR /&gt;h&lt;BR /&gt;j&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;I need to find if this input contains test1 AND test2 !!!&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 05 Jun 2009 17:25:50 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/egrep-and-patterns/m-p/4434054#M36870</guid>
      <dc:creator>Leo The Cat</dc:creator>
      <dc:date>2009-06-05T17:25:50Z</dc:date>
    </item>
    <item>
      <title>Re: egrep and patterns</title>
      <link>https://community.hpe.com/t5/operating-system-linux/egrep-and-patterns/m-p/4434055#M36871</link>
      <description>Please refer to this thread:&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://forums13.itrc.hp.com/service/forums/questionanswer.do?admit=109447627+1244229489824+28353475&amp;amp;threadId=1320198" target="_blank"&gt;http://forums13.itrc.hp.com/service/forums/questionanswer.do?admit=109447627+1244229489824+28353475&amp;amp;threadId=1320198&lt;/A&gt;</description>
      <pubDate>Fri, 05 Jun 2009 18:18:32 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/egrep-and-patterns/m-p/4434055#M36871</guid>
      <dc:creator>Ivan Ferreira</dc:creator>
      <dc:date>2009-06-05T18:18:32Z</dc:date>
    </item>
    <item>
      <title>Re: egrep and patterns</title>
      <link>https://community.hpe.com/t5/operating-system-linux/egrep-and-patterns/m-p/4434056#M36872</link>
      <description>Hi Den:&lt;BR /&gt;&lt;BR /&gt;This is one way (if you insist on 'grep') but requires two passes of your input:&lt;BR /&gt;&lt;BR /&gt;# grep -q test1 myfile &amp;amp;&amp;amp; grep -q test2 myfile &amp;amp;&amp;amp; echo "ok" || echo "no match"&lt;BR /&gt;&lt;BR /&gt;A faster way would be to use Perl or awk like:&lt;BR /&gt;&lt;BR /&gt;# perl -nle 'm/test2/ and $x=1;m/test1/ and $y=1;last if $x+$y==2;END{print $x+$y==2 ? "ok" : "nomatch"}' myfile&lt;BR /&gt;&lt;BR /&gt;By the way, you have un-evaluated solutions in your earlier thread:&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://forums.itrc.hp.com/service/forums/questionanswer.do?threadId=1344958" target="_blank"&gt;http://forums.itrc.hp.com/service/forums/questionanswer.do?threadId=1344958&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Feedback there too is appreciated :-)&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Fri, 05 Jun 2009 20:19:47 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/egrep-and-patterns/m-p/4434056#M36872</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2009-06-05T20:19:47Z</dc:date>
    </item>
    <item>
      <title>Re: egrep and patterns</title>
      <link>https://community.hpe.com/t5/operating-system-linux/egrep-and-patterns/m-p/4434057#M36873</link>
      <description>Hi (again) Den:&lt;BR /&gt;&lt;BR /&gt;In the event that you want more than a "yes/no" answer to the presence of the AND'ed match (as I provided in the first solutions, above) you could use:&lt;BR /&gt;&lt;BR /&gt;# grep -q test1 myfile &amp;amp;&amp;amp; grep -q test2 myfile &amp;amp;&amp;amp; grep -E "test1|test2" myfile&lt;BR /&gt;&lt;BR /&gt;...which again "suffers" from multiple passes through the file.&lt;BR /&gt;&lt;BR /&gt;...OR in one pass of the file:&lt;BR /&gt;&lt;BR /&gt;# perl -nle 'm/test1/ and $x=1,push(@a,$_),next;m/test2/ and $y=1,push(@a,$_),next;END{if ($x&amp;amp;&amp;amp;$y) {print for (@a)}}' myfile  &lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...&lt;BR /&gt;</description>
      <pubDate>Fri, 05 Jun 2009 23:29:33 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/egrep-and-patterns/m-p/4434057#M36873</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2009-06-05T23:29:33Z</dc:date>
    </item>
    <item>
      <title>Re: egrep and patterns</title>
      <link>https://community.hpe.com/t5/operating-system-linux/egrep-and-patterns/m-p/4434058#M36874</link>
      <description>&lt;!--!*#--&gt;you just use awk&lt;BR /&gt;&lt;BR /&gt;awk '/test1/{s[FNR]=$0}/test2/{f=1;s[FNR]=$0}END{if (f){for(i in s) print s[i]}}' file</description>
      <pubDate>Fri, 05 Jun 2009 23:43:40 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/egrep-and-patterns/m-p/4434058#M36874</guid>
      <dc:creator>ghostdog74</dc:creator>
      <dc:date>2009-06-05T23:43:40Z</dc:date>
    </item>
    <item>
      <title>Re: egrep and patterns</title>
      <link>https://community.hpe.com/t5/operating-system-linux/egrep-and-patterns/m-p/4434059#M36875</link>
      <description>&amp;gt;patterns are not in the same line&lt;BR /&gt;&lt;BR /&gt;You can use multiple passes of grep like JRF said:&lt;BR /&gt;grep test1 $(grep -l test2 file-list)</description>
      <pubDate>Sat, 06 Jun 2009 10:27:18 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/egrep-and-patterns/m-p/4434059#M36875</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2009-06-06T10:27:18Z</dc:date>
    </item>
    <item>
      <title>Re: egrep and patterns</title>
      <link>https://community.hpe.com/t5/operating-system-linux/egrep-and-patterns/m-p/4434060#M36876</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;what about simple:&lt;BR /&gt;&lt;BR /&gt;grep -e test1 -e test2 &lt;INPUT file="" /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;emha.</description>
      <pubDate>Sat, 06 Jun 2009 15:07:22 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/egrep-and-patterns/m-p/4434060#M36876</guid>
      <dc:creator>emha_1</dc:creator>
      <dc:date>2009-06-06T15:07:22Z</dc:date>
    </item>
    <item>
      <title>Re: egrep and patterns</title>
      <link>https://community.hpe.com/t5/operating-system-linux/egrep-and-patterns/m-p/4434061#M36877</link>
      <description>&amp;gt;grep -e test1 -e test2 &lt;INPUT file="" /&gt;&lt;BR /&gt;&lt;BR /&gt;if file only has test1 and not test2, then it will not work.</description>
      <pubDate>Sat, 06 Jun 2009 23:28:58 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/egrep-and-patterns/m-p/4434061#M36877</guid>
      <dc:creator>ghostdog74</dc:creator>
      <dc:date>2009-06-06T23:28:58Z</dc:date>
    </item>
    <item>
      <title>Re: egrep and patterns</title>
      <link>https://community.hpe.com/t5/operating-system-linux/egrep-and-patterns/m-p/4434062#M36878</link>
      <description>&lt;BR /&gt;&amp;gt;if file only has test1 and not test2, then it will not work&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;you are right, I'm wrong.&lt;BR /&gt;as the grep is line matching tool, I haven't realized original question was 'to find the FILE that contains both the lines test1 and test2'.&lt;BR /&gt;I understood it to list lines from input that contains test1 and test2.&lt;BR /&gt;&lt;BR /&gt;emha.</description>
      <pubDate>Tue, 09 Jun 2009 11:02:32 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/egrep-and-patterns/m-p/4434062#M36878</guid>
      <dc:creator>emha_1</dc:creator>
      <dc:date>2009-06-09T11:02:32Z</dc:date>
    </item>
  </channel>
</rss>

