<?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 and &amp;quot;AND&amp;quot; in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/grep-and-quot-and-quot/m-p/3041962#M76215</link>
    <description>This command should do it:&lt;BR /&gt;&lt;BR /&gt;grep "^[^#]bcd" file&lt;BR /&gt;&lt;BR /&gt;The [^#] is basically saying "not #".&lt;BR /&gt;&lt;BR /&gt;But the leading ^ (outside of the []'s) will say that it needs to be at the start of the line, but it also takes up a character space.&lt;BR /&gt;&lt;BR /&gt;This brings us to some more regular expression fun:&lt;BR /&gt;&lt;BR /&gt;grep "^[^#]*abcd" file&lt;BR /&gt;&lt;BR /&gt;will match properly as requested.  The * obviously meaning '0 or more' of the previous atom (character not # which is at the start of a string)...&lt;BR /&gt;&lt;BR /&gt;yay.. fun.. Ok, so I started in one direction, found the proper one, and couldn't be bothered re-typing the response ;P</description>
    <pubDate>Tue, 05 Aug 2003 22:59:10 GMT</pubDate>
    <dc:creator>Stuart Browne</dc:creator>
    <dc:date>2003-08-05T22:59:10Z</dc:date>
    <item>
      <title>grep and "AND"</title>
      <link>https://community.hpe.com/t5/operating-system-linux/grep-and-quot-and-quot/m-p/3041958#M76211</link>
      <description>hi gurus&lt;BR /&gt;am stuck with this for quite some time now. googling doesnt help.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;let us say my file is like this&lt;BR /&gt;*****************************&lt;BR /&gt;#a&lt;BR /&gt;abcd&lt;BR /&gt;#abcd&lt;BR /&gt;abcd1&lt;BR /&gt;*******************************&lt;BR /&gt;&lt;BR /&gt;i want to find out all occurances of abcd which  doesnt have this comment. &lt;BR /&gt;&lt;BR /&gt;i know this&lt;BR /&gt;&lt;BR /&gt;grep -v ^# file | grep "abcd" file.&lt;BR /&gt;&lt;BR /&gt;but is it possible to do this in a single grep.&lt;BR /&gt;&lt;BR /&gt;something like this&lt;BR /&gt;&lt;BR /&gt;grep -e (^#|abcd) file &lt;BR /&gt;&lt;BR /&gt;will matach either of this pattern.&lt;BR /&gt;&lt;BR /&gt;is there something will match both the pattern (the AND clause).&lt;BR /&gt;&lt;BR /&gt;thanks for all the help. am stuck at this moment and bunnies for quick answers.&lt;BR /&gt;-balaji&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 05 Aug 2003 19:46:17 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/grep-and-quot-and-quot/m-p/3041958#M76211</guid>
      <dc:creator>Balaji N</dc:creator>
      <dc:date>2003-08-05T19:46:17Z</dc:date>
    </item>
    <item>
      <title>Re: grep and "AND"</title>
      <link>https://community.hpe.com/t5/operating-system-linux/grep-and-quot-and-quot/m-p/3041959#M76212</link>
      <description>grep abcd file.text | grep -v ^#&lt;BR /&gt;&lt;BR /&gt;output:&lt;BR /&gt;&lt;BR /&gt;abcd&lt;BR /&gt;abcd1&lt;BR /&gt;&lt;BR /&gt;worked for me in HP-UX?&lt;BR /&gt;&lt;BR /&gt;What about Linux? Or do I not understand the question?&lt;BR /&gt;&lt;BR /&gt;SEP</description>
      <pubDate>Tue, 05 Aug 2003 20:08:29 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/grep-and-quot-and-quot/m-p/3041959#M76212</guid>
      <dc:creator>Steven E. Protter</dc:creator>
      <dc:date>2003-08-05T20:08:29Z</dc:date>
    </item>
    <item>
      <title>Re: grep and "AND"</title>
      <link>https://community.hpe.com/t5/operating-system-linux/grep-and-quot-and-quot/m-p/3041960#M76213</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;I got this to work:&lt;BR /&gt;&lt;BR /&gt;grep "^abcd" file&lt;BR /&gt;&lt;BR /&gt;but I don't think it is exactly what you are &lt;BR /&gt;looking for, as it will fail to find:&lt;BR /&gt;&lt;BR /&gt;# abcd&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;SEP, the way you mentioned works but Balaji&lt;BR /&gt;is looking to do it with a single grep command.&lt;BR /&gt;&lt;BR /&gt;JP&lt;BR /&gt;</description>
      <pubDate>Tue, 05 Aug 2003 20:16:04 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/grep-and-quot-and-quot/m-p/3041960#M76213</guid>
      <dc:creator>John Poff</dc:creator>
      <dc:date>2003-08-05T20:16:04Z</dc:date>
    </item>
    <item>
      <title>Re: grep and "AND"</title>
      <link>https://community.hpe.com/t5/operating-system-linux/grep-and-quot-and-quot/m-p/3041961#M76214</link>
      <description>hi SEP,&lt;BR /&gt;i am looking for that to be done in a single grep.&lt;BR /&gt;&lt;BR /&gt;is there a way do it without piping in the output to grep.&lt;BR /&gt;&lt;BR /&gt;-balaji</description>
      <pubDate>Tue, 05 Aug 2003 20:35:24 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/grep-and-quot-and-quot/m-p/3041961#M76214</guid>
      <dc:creator>Balaji N</dc:creator>
      <dc:date>2003-08-05T20:35:24Z</dc:date>
    </item>
    <item>
      <title>Re: grep and "AND"</title>
      <link>https://community.hpe.com/t5/operating-system-linux/grep-and-quot-and-quot/m-p/3041962#M76215</link>
      <description>This command should do it:&lt;BR /&gt;&lt;BR /&gt;grep "^[^#]bcd" file&lt;BR /&gt;&lt;BR /&gt;The [^#] is basically saying "not #".&lt;BR /&gt;&lt;BR /&gt;But the leading ^ (outside of the []'s) will say that it needs to be at the start of the line, but it also takes up a character space.&lt;BR /&gt;&lt;BR /&gt;This brings us to some more regular expression fun:&lt;BR /&gt;&lt;BR /&gt;grep "^[^#]*abcd" file&lt;BR /&gt;&lt;BR /&gt;will match properly as requested.  The * obviously meaning '0 or more' of the previous atom (character not # which is at the start of a string)...&lt;BR /&gt;&lt;BR /&gt;yay.. fun.. Ok, so I started in one direction, found the proper one, and couldn't be bothered re-typing the response ;P</description>
      <pubDate>Tue, 05 Aug 2003 22:59:10 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/grep-and-quot-and-quot/m-p/3041962#M76215</guid>
      <dc:creator>Stuart Browne</dc:creator>
      <dc:date>2003-08-05T22:59:10Z</dc:date>
    </item>
    <item>
      <title>Re: grep and "AND"</title>
      <link>https://community.hpe.com/t5/operating-system-linux/grep-and-quot-and-quot/m-p/3041963#M76216</link>
      <description>I've tested the final solutions of all contestants and they all work.&lt;BR /&gt;&lt;BR /&gt;I always love Stuart's answers&lt;BR /&gt;grep "^[^#]bcd"&lt;BR /&gt;&lt;BR /&gt;output&lt;BR /&gt;&lt;BR /&gt;abcd&lt;BR /&gt;abcd1&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;I knew it wasn't so easy as my answer.  It would be nice to know however why two greps are a problem.  Overhead?  Or just looking for an elegant solution.&lt;BR /&gt;&lt;BR /&gt;Apologies for my misunderstanding.  Feel free to zero point both posts.&lt;BR /&gt;&lt;BR /&gt;:-)&lt;BR /&gt;&lt;BR /&gt;SEP</description>
      <pubDate>Wed, 06 Aug 2003 00:20:30 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/grep-and-quot-and-quot/m-p/3041963#M76216</guid>
      <dc:creator>Steven E. Protter</dc:creator>
      <dc:date>2003-08-06T00:20:30Z</dc:date>
    </item>
    <item>
      <title>Re: grep and "AND"</title>
      <link>https://community.hpe.com/t5/operating-system-linux/grep-and-quot-and-quot/m-p/3041964#M76217</link>
      <description>i'd use &lt;BR /&gt;&lt;BR /&gt;cat file | grep ^abcd&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 06 Aug 2003 16:05:06 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/grep-and-quot-and-quot/m-p/3041964#M76217</guid>
      <dc:creator>John Meissner</dc:creator>
      <dc:date>2003-08-06T16:05:06Z</dc:date>
    </item>
    <item>
      <title>Re: grep and "AND"</title>
      <link>https://community.hpe.com/t5/operating-system-linux/grep-and-quot-and-quot/m-p/3041965#M76218</link>
      <description>sed masters in being one process:&lt;BR /&gt;&lt;BR /&gt;sed -n -e '/^#/d' -e '/abcd/p' &amp;lt; file&lt;BR /&gt;&lt;BR /&gt;regards&lt;BR /&gt;Wouter</description>
      <pubDate>Thu, 07 Aug 2003 00:57:00 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/grep-and-quot-and-quot/m-p/3041965#M76218</guid>
      <dc:creator>Wouter Jagers</dc:creator>
      <dc:date>2003-08-07T00:57:00Z</dc:date>
    </item>
  </channel>
</rss>

