<?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: strange behavior using grep command in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/strange-behavior-using-grep-command/m-p/7149814#M495912</link>
    <description>&lt;P&gt;Hi Duncan,&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you so much.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Not so dirty!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In fact my code is now something like that, so I tested your trick and it works.&amp;nbsp;&lt;/P&gt;&lt;P&gt;VG=`echo "$theLVlist" | grep -w "${FS}$" | awk -F "::::" '{print $1}'`&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Kind regards,&lt;/P&gt;&lt;P&gt;Den.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 23 Sep 2021 11:59:17 GMT</pubDate>
    <dc:creator>SwissKnife</dc:creator>
    <dc:date>2021-09-23T11:59:17Z</dc:date>
    <item>
      <title>strange behavior using grep command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/strange-behavior-using-grep-command/m-p/7149778#M495910</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;here is my input file&lt;/P&gt;&lt;P&gt;sanvg1::::lv_logiciel /logiciel&lt;BR /&gt;sanvg1::::loglv00&amp;nbsp; N/A&lt;BR /&gt;sanvg1::::lv_oradiag&amp;nbsp; /logiciel/app/oracle/diag&lt;BR /&gt;sanvg1::::lv_exp0x00&amp;nbsp; /exp0x00&lt;BR /&gt;sanvg1::::lvbase&amp;nbsp; /base&lt;/P&gt;&lt;P&gt;I need to grep /logiciel&lt;/P&gt;&lt;P&gt;but&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;cat myfile | grep -w "/logiciel"&amp;nbsp;&lt;/P&gt;&lt;P&gt;returns /logiciel but also /logiciel/app/oracle/diag&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How to grep the exact substring ?&lt;/P&gt;&lt;P&gt;Thanks in advance,&lt;/P&gt;&lt;P&gt;Kind regards,&lt;/P&gt;&lt;P&gt;Den.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Sep 2021 11:47:41 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/strange-behavior-using-grep-command/m-p/7149778#M495910</guid>
      <dc:creator>SwissKnife</dc:creator>
      <dc:date>2021-09-23T11:47:41Z</dc:date>
    </item>
    <item>
      <title>Re: strange behavior using grep command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/strange-behavior-using-grep-command/m-p/7149809#M495911</link>
      <description>&lt;P&gt;Here's the man page for the -w option of grep:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;-w                          Select only those lines containing matches
                               that form whole words. The test is that the
                               matching substring must either be at the
                               beginning of the line, or preceded by a nonword
                               constituent character.  Similarly, it
                               must be either at the end of the line or
                               followed by a non-word constituent character.
                               Word-constituent characters are letters,
                               digits, and the underscore.&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So "/" is a "non-word consituent character", so it is considering the&amp;nbsp;&amp;nbsp;"/logiciel" part to be a seperate word from "/app/oracle/diag" (which it would also consider seperate words)&lt;/P&gt;&lt;P&gt;Quick and dirty fix I guess would be that as you know the field you want to match on is at the end of the line you could instead use&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;grep "/logiciel$" myfile&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Sep 2021 10:40:01 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/strange-behavior-using-grep-command/m-p/7149809#M495911</guid>
      <dc:creator>Duncan Edmonstone</dc:creator>
      <dc:date>2021-09-23T10:40:01Z</dc:date>
    </item>
    <item>
      <title>Re: strange behavior using grep command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/strange-behavior-using-grep-command/m-p/7149814#M495912</link>
      <description>&lt;P&gt;Hi Duncan,&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you so much.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Not so dirty!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In fact my code is now something like that, so I tested your trick and it works.&amp;nbsp;&lt;/P&gt;&lt;P&gt;VG=`echo "$theLVlist" | grep -w "${FS}$" | awk -F "::::" '{print $1}'`&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Kind regards,&lt;/P&gt;&lt;P&gt;Den.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Sep 2021 11:59:17 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/strange-behavior-using-grep-command/m-p/7149814#M495912</guid>
      <dc:creator>SwissKnife</dc:creator>
      <dc:date>2021-09-23T11:59:17Z</dc:date>
    </item>
  </channel>
</rss>

