<?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 command in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/grep-command/m-p/2554173#M724922</link>
    <description>#!/sbin/sh &lt;BR /&gt;echo &amp;gt; /tmp/list &lt;BR /&gt;for i in 'cat /tmp/hplist' &lt;BR /&gt;do &lt;BR /&gt;grep $i$ /etc/hosts &amp;gt;&amp;gt; /tmp/list &lt;BR /&gt;done &lt;BR /&gt;</description>
    <pubDate>Wed, 18 Jul 2001 08:45:00 GMT</pubDate>
    <dc:creator>federico_3</dc:creator>
    <dc:date>2001-07-18T08:45:00Z</dc:date>
    <item>
      <title>grep command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/grep-command/m-p/2554168#M724917</link>
      <description>I work on hp systems. I want to find some entries in the /etc/hosts. I wrote a script, but while i issue the grep command i have some problems.&lt;BR /&gt;For example if i make grep hp1 /etc/hosts i will see all ws that begins with hp1 so also hp12, hp110, hp19 and so on..&lt;BR /&gt;I want to find only hp1. I know that with sun the command is grep -w, but this doesn't exist on hp, what is it's correspondance? I looked in the grep's man, but i didn't find it. (maybe i didn't look well!!)</description>
      <pubDate>Wed, 18 Jul 2001 07:54:36 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/grep-command/m-p/2554168#M724917</guid>
      <dc:creator>Tarek</dc:creator>
      <dc:date>2001-07-18T07:54:36Z</dc:date>
    </item>
    <item>
      <title>Re: grep command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/grep-command/m-p/2554169#M724918</link>
      <description>You could replace the grep command with perl.  Perl has a smarter regexp syntax :&lt;BR /&gt;&lt;BR /&gt;# perl -ne '/\bhp1\b/ &amp;amp;&amp;amp; print' /etc/hosts&lt;BR /&gt;&lt;BR /&gt;(\b stands for word boundary)&lt;BR /&gt;</description>
      <pubDate>Wed, 18 Jul 2001 08:14:29 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/grep-command/m-p/2554169#M724918</guid>
      <dc:creator>Laurent Paumier</dc:creator>
      <dc:date>2001-07-18T08:14:29Z</dc:date>
    </item>
    <item>
      <title>Re: grep command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/grep-command/m-p/2554170#M724919</link>
      <description>Hi there.&lt;BR /&gt;Try this :&lt;BR /&gt;&lt;BR /&gt;grep 'hp1 ' /etc/hosts&lt;BR /&gt;&lt;BR /&gt;Rgds&lt;BR /&gt;Alexander M. Ermes</description>
      <pubDate>Wed, 18 Jul 2001 08:18:09 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/grep-command/m-p/2554170#M724919</guid>
      <dc:creator>Alexander M. Ermes</dc:creator>
      <dc:date>2001-07-18T08:18:09Z</dc:date>
    </item>
    <item>
      <title>Re: grep command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/grep-command/m-p/2554171#M724920</link>
      <description>Thanks to both!! But i have still a problem. How can i implement your code in the script.&lt;BR /&gt;#!/sbin/sh&lt;BR /&gt;echo &amp;gt; /tmp/list&lt;BR /&gt;for i in 'cat /tmp/hplist'&lt;BR /&gt;do&lt;BR /&gt;  grep $i /etc/hosts &amp;gt;&amp;gt; /tmp/list&lt;BR /&gt;done&lt;BR /&gt;I saw that if i put $i between '$i ', the output is wrong.</description>
      <pubDate>Wed, 18 Jul 2001 08:27:52 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/grep-command/m-p/2554171#M724920</guid>
      <dc:creator>Tarek</dc:creator>
      <dc:date>2001-07-18T08:27:52Z</dc:date>
    </item>
    <item>
      <title>Re: grep command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/grep-command/m-p/2554172#M724921</link>
      <description>I'd do like the following :&lt;BR /&gt;&lt;BR /&gt;grep hp1$ /etc/hosts</description>
      <pubDate>Wed, 18 Jul 2001 08:34:43 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/grep-command/m-p/2554172#M724921</guid>
      <dc:creator>federico_3</dc:creator>
      <dc:date>2001-07-18T08:34:43Z</dc:date>
    </item>
    <item>
      <title>Re: grep command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/grep-command/m-p/2554173#M724922</link>
      <description>#!/sbin/sh &lt;BR /&gt;echo &amp;gt; /tmp/list &lt;BR /&gt;for i in 'cat /tmp/hplist' &lt;BR /&gt;do &lt;BR /&gt;grep $i$ /etc/hosts &amp;gt;&amp;gt; /tmp/list &lt;BR /&gt;done &lt;BR /&gt;</description>
      <pubDate>Wed, 18 Jul 2001 08:45:00 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/grep-command/m-p/2554173#M724922</guid>
      <dc:creator>federico_3</dc:creator>
      <dc:date>2001-07-18T08:45:00Z</dc:date>
    </item>
    <item>
      <title>Re: grep command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/grep-command/m-p/2554174#M724923</link>
      <description>hi,&lt;BR /&gt;grep "$i " ...&lt;BR /&gt;instead of&lt;BR /&gt;grep '$i ' ...&lt;BR /&gt;With single quotes your variable will not be translated, and grep will search for $i (dollar-i) in your file.&lt;BR /&gt;regards,&lt;BR /&gt;Thierry.</description>
      <pubDate>Wed, 18 Jul 2001 08:50:58 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/grep-command/m-p/2554174#M724923</guid>
      <dc:creator>Thierry Poels_1</dc:creator>
      <dc:date>2001-07-18T08:50:58Z</dc:date>
    </item>
    <item>
      <title>Re: grep command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/grep-command/m-p/2554175#M724924</link>
      <description>The "$i " and $i$ works so and so. The problem is that they don't search every entry that i have in the list in /etc/hosts.&lt;BR /&gt;So the script isn't helpful.</description>
      <pubDate>Wed, 18 Jul 2001 09:44:30 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/grep-command/m-p/2554175#M724924</guid>
      <dc:creator>Tarek</dc:creator>
      <dc:date>2001-07-18T09:44:30Z</dc:date>
    </item>
    <item>
      <title>Re: grep command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/grep-command/m-p/2554176#M724925</link>
      <description>grep -e "$i[       ]" -e $i$ /etc/hosts&lt;BR /&gt;&lt;BR /&gt;where you type space followed by tab in the square brackets.&lt;BR /&gt;&lt;BR /&gt;If this doesn't work, what type of expression is not being captured?&lt;BR /&gt;&lt;BR /&gt;Robin.</description>
      <pubDate>Wed, 18 Jul 2001 10:11:03 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/grep-command/m-p/2554176#M724925</guid>
      <dc:creator>Robin Wakefield</dc:creator>
      <dc:date>2001-07-18T10:11:03Z</dc:date>
    </item>
    <item>
      <title>Re: grep command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/grep-command/m-p/2554177#M724926</link>
      <description>...or try this too:&lt;BR /&gt;&lt;BR /&gt;grep -E "$i( |    |$)" /etc/hosts&lt;BR /&gt;&lt;BR /&gt;again, it's space,pipe,tab,pipe,dollar in the brackets.&lt;BR /&gt;&lt;BR /&gt;Robin.</description>
      <pubDate>Wed, 18 Jul 2001 10:19:50 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/grep-command/m-p/2554177#M724926</guid>
      <dc:creator>Robin Wakefield</dc:creator>
      <dc:date>2001-07-18T10:19:50Z</dc:date>
    </item>
    <item>
      <title>Re: grep command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/grep-command/m-p/2554178#M724927</link>
      <description>The hostnames in my hosts file usually have a tab after the name.  The following works for me:&lt;BR /&gt;&lt;BR /&gt;grep "hp1[  ]" hosts&lt;BR /&gt;&lt;BR /&gt;The first character in the brackets is a space, the second character is where I pressed the tab key (on my system it actually show many more spaces)  That way it will get those that end in spaces or those that end in a tab character.</description>
      <pubDate>Wed, 18 Jul 2001 10:59:08 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/grep-command/m-p/2554178#M724927</guid>
      <dc:creator>Tracey</dc:creator>
      <dc:date>2001-07-18T10:59:08Z</dc:date>
    </item>
    <item>
      <title>Re: grep command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/grep-command/m-p/2554179#M724928</link>
      <description>How about rewriting the whole script ?&lt;BR /&gt;Here's what you could du using awk :&lt;BR /&gt;&lt;BR /&gt;awk '&lt;BR /&gt;BEGIN {&lt;BR /&gt;  while (getline &amp;lt;"/etc/hosts") {&lt;BR /&gt;    for (i=1;i&amp;lt;=NF;i++) {&lt;BR /&gt;      host[$i]=$0&lt;BR /&gt;    }&lt;BR /&gt;  }&lt;BR /&gt;  while (getline &amp;lt;"/tmp/hplist") {&lt;BR /&gt;    printf("%s\n",host[$0])&lt;BR /&gt;  }&lt;BR /&gt;}' &amp;gt;/tmp/list&lt;BR /&gt;</description>
      <pubDate>Wed, 18 Jul 2001 11:31:41 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/grep-command/m-p/2554179#M724928</guid>
      <dc:creator>Laurent Paumier</dc:creator>
      <dc:date>2001-07-18T11:31:41Z</dc:date>
    </item>
    <item>
      <title>Re: grep command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/grep-command/m-p/2554180#M724929</link>
      <description>That's it Robin!!! The second code was the right one.&lt;BR /&gt;I tried also yours Laurent, it works, but there are some entries that aren't found.&lt;BR /&gt;However i'd like to learn something about using awk, it seems very powerful, is there some tutorial on the net?&lt;BR /&gt;Thanks both, and of course thanks to all for your kindly help.&lt;BR /&gt;Regards&lt;BR /&gt;Tarek</description>
      <pubDate>Wed, 18 Jul 2001 11:55:51 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/grep-command/m-p/2554180#M724929</guid>
      <dc:creator>Tarek</dc:creator>
      <dc:date>2001-07-18T11:55:51Z</dc:date>
    </item>
    <item>
      <title>Re: grep command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/grep-command/m-p/2554181#M724930</link>
      <description>Tarek, try:&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://vectorsite.tripod.com/tsawk0.html" target="_blank"&gt;http://vectorsite.tripod.com/tsawk0.html&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Robin</description>
      <pubDate>Wed, 18 Jul 2001 12:26:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/grep-command/m-p/2554181#M724930</guid>
      <dc:creator>Robin Wakefield</dc:creator>
      <dc:date>2001-07-18T12:26:35Z</dc:date>
    </item>
  </channel>
</rss>

