<?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 doesn't work in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/egrep-doesn-t-work/m-p/2972038#M120563</link>
    <description>Hi everybody&lt;BR /&gt;This question is for real UNIX-cracks ;-)&lt;BR /&gt;&lt;BR /&gt;Initial position:&lt;BR /&gt;script:                       /etc/profile.company-sysconf&lt;BR /&gt;called file from the script:  /tools/data/domain&lt;BR /&gt;  - directory /tools/   have drwxr-xr-x  root  root&lt;BR /&gt;  - directory /data     have drwxr-xr-x  snml  dba&lt;BR /&gt;  - file 'domain'       have -rwxr-xr-x  snml  dba&lt;BR /&gt;&lt;BR /&gt;We have a shell-script with the command:&lt;BR /&gt;cat /tools/data/domain | egrep [a-z]&lt;BR /&gt;&lt;BR /&gt;We use this command on 53 machines. It works fine on 52 machines. It doesn't work only by one (!!!) machine.&lt;BR /&gt;All machines are similar.&lt;BR /&gt;The script and the file 'domain' are both copys from a other machine (we tried it from different machines).&lt;BR /&gt;We think, it isn't the problem from the script, because if we make this 'cat ..| egrep' command from the command line it doesn't work too!&lt;BR /&gt;&lt;BR /&gt;It works with the following 'settings':&lt;BR /&gt;root# cd /tools/data/&lt;BR /&gt;root# cat domain | egrep [a-z]   --&amp;gt; fine&lt;BR /&gt;&lt;BR /&gt;root# cd /&lt;BR /&gt;root# cat /tools/data/domain --&amp;gt; fine  (without egrep)&lt;BR /&gt;&lt;BR /&gt;other users$ cat /tools/data/domain | egrep [a-z] --&amp;gt; fine&lt;BR /&gt;&lt;BR /&gt;It DOESN'T work only with root (!!):&lt;BR /&gt;root# cat /tools/data/domain | egrep [a-z]   --&amp;gt; bad&lt;BR /&gt;&lt;BR /&gt;We was checking also the environments, we think everything is the same.&lt;BR /&gt;&lt;BR /&gt;Have somebody any ideas. It is very strange&lt;BR /&gt;Thank you very much  - Konrad</description>
    <pubDate>Tue, 13 May 2003 13:34:39 GMT</pubDate>
    <dc:creator>Konrad Hegner</dc:creator>
    <dc:date>2003-05-13T13:34:39Z</dc:date>
    <item>
      <title>egrep doesn't work</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/egrep-doesn-t-work/m-p/2972038#M120563</link>
      <description>Hi everybody&lt;BR /&gt;This question is for real UNIX-cracks ;-)&lt;BR /&gt;&lt;BR /&gt;Initial position:&lt;BR /&gt;script:                       /etc/profile.company-sysconf&lt;BR /&gt;called file from the script:  /tools/data/domain&lt;BR /&gt;  - directory /tools/   have drwxr-xr-x  root  root&lt;BR /&gt;  - directory /data     have drwxr-xr-x  snml  dba&lt;BR /&gt;  - file 'domain'       have -rwxr-xr-x  snml  dba&lt;BR /&gt;&lt;BR /&gt;We have a shell-script with the command:&lt;BR /&gt;cat /tools/data/domain | egrep [a-z]&lt;BR /&gt;&lt;BR /&gt;We use this command on 53 machines. It works fine on 52 machines. It doesn't work only by one (!!!) machine.&lt;BR /&gt;All machines are similar.&lt;BR /&gt;The script and the file 'domain' are both copys from a other machine (we tried it from different machines).&lt;BR /&gt;We think, it isn't the problem from the script, because if we make this 'cat ..| egrep' command from the command line it doesn't work too!&lt;BR /&gt;&lt;BR /&gt;It works with the following 'settings':&lt;BR /&gt;root# cd /tools/data/&lt;BR /&gt;root# cat domain | egrep [a-z]   --&amp;gt; fine&lt;BR /&gt;&lt;BR /&gt;root# cd /&lt;BR /&gt;root# cat /tools/data/domain --&amp;gt; fine  (without egrep)&lt;BR /&gt;&lt;BR /&gt;other users$ cat /tools/data/domain | egrep [a-z] --&amp;gt; fine&lt;BR /&gt;&lt;BR /&gt;It DOESN'T work only with root (!!):&lt;BR /&gt;root# cat /tools/data/domain | egrep [a-z]   --&amp;gt; bad&lt;BR /&gt;&lt;BR /&gt;We was checking also the environments, we think everything is the same.&lt;BR /&gt;&lt;BR /&gt;Have somebody any ideas. It is very strange&lt;BR /&gt;Thank you very much  - Konrad</description>
      <pubDate>Tue, 13 May 2003 13:34:39 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/egrep-doesn-t-work/m-p/2972038#M120563</guid>
      <dc:creator>Konrad Hegner</dc:creator>
      <dc:date>2003-05-13T13:34:39Z</dc:date>
    </item>
    <item>
      <title>Re: egrep doesn't work</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/egrep-doesn-t-work/m-p/2972039#M120564</link>
      <description>Do a which egrep as user and as root - are they the same?&lt;BR /&gt;&lt;BR /&gt;You might need to use explicit path:&lt;BR /&gt;&lt;BR /&gt;/usr/bin/egrep&lt;BR /&gt;&lt;BR /&gt;Rgds...Geoff</description>
      <pubDate>Tue, 13 May 2003 13:39:36 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/egrep-doesn-t-work/m-p/2972039#M120564</guid>
      <dc:creator>Geoff Wild</dc:creator>
      <dc:date>2003-05-13T13:39:36Z</dc:date>
    </item>
    <item>
      <title>Re: egrep doesn't work</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/egrep-doesn-t-work/m-p/2972040#M120565</link>
      <description>1. Why use cat? I've mentioned this many times before: it's a plain waste of computer resources&lt;BR /&gt;&lt;BR /&gt;# egrep [a-z] /tools/data/domain&lt;BR /&gt;&lt;BR /&gt;works much more efficient&lt;BR /&gt;&lt;BR /&gt;2. the fact that it does not run most likely finds its existance in the fact that a file exists with a one character name in the rang of a..z&lt;BR /&gt;&lt;BR /&gt;You should quote th regular expression, because it is also recognized by the shell&lt;BR /&gt;&lt;BR /&gt;So, .... how does&lt;BR /&gt;&lt;BR /&gt;# egrep '[a-z]' /tools/data/domain&lt;BR /&gt;&lt;BR /&gt;work for you?&lt;BR /&gt;&lt;BR /&gt;Are the versions of (e)grep the same along the line of machines?&lt;BR /&gt;&lt;BR /&gt;Enjoy, have FUN! H.Merijn</description>
      <pubDate>Tue, 13 May 2003 13:45:05 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/egrep-doesn-t-work/m-p/2972040#M120565</guid>
      <dc:creator>H.Merijn Brand (procura</dc:creator>
      <dc:date>2003-05-13T13:45:05Z</dc:date>
    </item>
    <item>
      <title>Re: egrep doesn't work</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/egrep-doesn-t-work/m-p/2972041#M120566</link>
      <description>Your root account is picking up egrep from a different path than other accounts.&lt;BR /&gt;&lt;BR /&gt;Use 'type egrep' to find out where from.&lt;BR /&gt;&lt;BR /&gt;BTW egrep is obsolescent.&lt;BR /&gt;You should use grep -E.&lt;BR /&gt;&lt;BR /&gt;And, as per previous post, the use of 'cat' is superfluous&lt;BR /&gt;&lt;BR /&gt;-- Graham</description>
      <pubDate>Wed, 14 May 2003 06:24:05 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/egrep-doesn-t-work/m-p/2972041#M120566</guid>
      <dc:creator>Graham Cameron_1</dc:creator>
      <dc:date>2003-05-14T06:24:05Z</dc:date>
    </item>
    <item>
      <title>Re: egrep doesn't work</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/egrep-doesn-t-work/m-p/2972042#M120567</link>
      <description>I agree with procure.&lt;BR /&gt;&lt;BR /&gt;you must enclose the pattern in single quotes. If not,&lt;BR /&gt;&lt;BR /&gt;[a-z]&lt;BR /&gt;&lt;BR /&gt;will be expanded to any file whose name matches this pattern. For example: a file whose name os 'a' exists in your current directory. The following command line:&lt;BR /&gt;&lt;BR /&gt;$ egrep [a-z] /etc/profile&lt;BR /&gt;&lt;BR /&gt;is execute as:&lt;BR /&gt;&lt;BR /&gt;$ egrep a /etc/profile&lt;BR /&gt;&lt;BR /&gt;This is because shell expands and substitutes file patterns.&lt;BR /&gt;If no filename matches the pattern, shell doesn't substitute the pattern.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 14 May 2003 08:22:30 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/egrep-doesn-t-work/m-p/2972042#M120567</guid>
      <dc:creator>Jdamian</dc:creator>
      <dc:date>2003-05-14T08:22:30Z</dc:date>
    </item>
    <item>
      <title>Re: egrep doesn't work</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/egrep-doesn-t-work/m-p/2972043#M120568</link>
      <description>Thanks for your answers.&lt;BR /&gt;&lt;BR /&gt;- /usr/bin/egrep doesn't help.&lt;BR /&gt;&lt;BR /&gt;- all egrep's are from /usr/bin/egrep (which or type command).&lt;BR /&gt;&lt;BR /&gt;-# egrep '[a-z]' /.../domain works fine (also with the cat-command). I think, this is a very good workaround, or it is THE solution.&lt;BR /&gt;&lt;BR /&gt;But why I have this problem only by one machine (from 53!)?&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;The tip to work without 'cat ... | egrep' is good, but for me it is easier to read the script if I use it in 'my way'. And for 'save' CPU time, it's definitiv not necessary. But thank you anyway - I'm a rookie and I have to learn a lot.</description>
      <pubDate>Wed, 14 May 2003 10:45:16 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/egrep-doesn-t-work/m-p/2972043#M120568</guid>
      <dc:creator>Konrad Hegner</dc:creator>
      <dc:date>2003-05-14T10:45:16Z</dc:date>
    </item>
    <item>
      <title>Re: egrep doesn't work</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/egrep-doesn-t-work/m-p/2972044#M120569</link>
      <description>The reason that egrep [a-z] fails for root can be demonstrated with this command:&lt;BR /&gt;&lt;BR /&gt;touch a&lt;BR /&gt;echo [a-z]&lt;BR /&gt;a&lt;BR /&gt;&lt;BR /&gt;In other words, the [a-z] is a regular expression which, unless enclosed in single quotes or the brakets escvaped with backslashes: \[a-x\] then the shell expands the expression BEFORE egrep ever sees the characters on the command line. Try this:&lt;BR /&gt;&lt;BR /&gt;echo ?&lt;BR /&gt;&lt;BR /&gt;You'll see all the files in the current directory that are exactly 1 character names. Another way to see this is to take your failing command and put echo in fron of it:&lt;BR /&gt;&lt;BR /&gt;echo egrep [a-z]&lt;BR /&gt;&lt;BR /&gt;then protect the expression:&lt;BR /&gt;&lt;BR /&gt;echo egrep '[a-z]'&lt;BR /&gt;&lt;BR /&gt;Most people forget that the shell automatically looks for regular expressions and tries to perform a match.&lt;BR /&gt;&lt;BR /&gt;In addition to the recommendation to not use cat into egrep, egrep itself is overkill since it has extra code to process extended regular expressions, and a character class such as [a-z] is no an extended regexp. Plain old grep will work fine with your example. An example of an extended regexp is:&lt;BR /&gt;&lt;BR /&gt;egrep 'err|warn|fail' some_file&lt;BR /&gt;&lt;BR /&gt;which finds all lines with any of the 3 strings. However, egrep isn't even necessary for the above task as multiple -e options will do the same thing:&lt;BR /&gt;&lt;BR /&gt;grep -e err -e warn -e fail some_file</description>
      <pubDate>Wed, 14 May 2003 11:17:29 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/egrep-doesn-t-work/m-p/2972044#M120569</guid>
      <dc:creator>Bill Hassell</dc:creator>
      <dc:date>2003-05-14T11:17:29Z</dc:date>
    </item>
  </channel>
</rss>

