<?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 script help in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/script-help/m-p/3030574#M132501</link>
    <description>Hi All&lt;BR /&gt;&lt;BR /&gt;I have a quick query about a script I am trying to put together&lt;BR /&gt;&lt;BR /&gt;I have a file full of address' I need to check wether the address' in the file resides in other files&lt;BR /&gt;&lt;BR /&gt;I have put this together at the moment&lt;BR /&gt;&lt;BR /&gt;for match in $(cat nomatch_add.dat)&lt;BR /&gt;do&lt;BR /&gt;newmatch=\'$match\'&lt;BR /&gt;grep $newmatch &lt;FILENAME&gt; &amp;gt; /tmp/totals&lt;BR /&gt;if [ $? = 0 ]&lt;BR /&gt;then&lt;BR /&gt;num=$(cat /tmp/totals)&lt;BR /&gt;echo "$match exists in &lt;FILENAME&gt; $num times"&lt;BR /&gt;fi&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;The problem I am having is with the newmatch. I thought that if I add ' to the start and end of the variable then grep would treat the variable as one entry to match. &lt;BR /&gt;&lt;BR /&gt;echo $match&lt;BR /&gt;2 HARROW LANE&lt;BR /&gt;&lt;BR /&gt;newmatch=\'$match\'&lt;BR /&gt;&lt;BR /&gt;echo $newmatch&lt;BR /&gt;'2 HARROW LANE'&lt;BR /&gt;&lt;BR /&gt;I get this though&lt;BR /&gt;&lt;BR /&gt;grep $newmatch &lt;FILENAME&gt;&lt;BR /&gt;&lt;BR /&gt;grep: can't open HARROW&lt;BR /&gt;grep: can't open LANE&lt;BR /&gt;grep: can't open '&lt;BR /&gt;&lt;BR /&gt;How can I resolve this &lt;BR /&gt;&lt;BR /&gt;Thanks in advance&lt;BR /&gt;&lt;BR /&gt;&lt;/FILENAME&gt;&lt;/FILENAME&gt;&lt;/FILENAME&gt;</description>
    <pubDate>Wed, 23 Jul 2003 00:21:19 GMT</pubDate>
    <dc:creator>Ian James_1</dc:creator>
    <dc:date>2003-07-23T00:21:19Z</dc:date>
    <item>
      <title>script help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-help/m-p/3030574#M132501</link>
      <description>Hi All&lt;BR /&gt;&lt;BR /&gt;I have a quick query about a script I am trying to put together&lt;BR /&gt;&lt;BR /&gt;I have a file full of address' I need to check wether the address' in the file resides in other files&lt;BR /&gt;&lt;BR /&gt;I have put this together at the moment&lt;BR /&gt;&lt;BR /&gt;for match in $(cat nomatch_add.dat)&lt;BR /&gt;do&lt;BR /&gt;newmatch=\'$match\'&lt;BR /&gt;grep $newmatch &lt;FILENAME&gt; &amp;gt; /tmp/totals&lt;BR /&gt;if [ $? = 0 ]&lt;BR /&gt;then&lt;BR /&gt;num=$(cat /tmp/totals)&lt;BR /&gt;echo "$match exists in &lt;FILENAME&gt; $num times"&lt;BR /&gt;fi&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;The problem I am having is with the newmatch. I thought that if I add ' to the start and end of the variable then grep would treat the variable as one entry to match. &lt;BR /&gt;&lt;BR /&gt;echo $match&lt;BR /&gt;2 HARROW LANE&lt;BR /&gt;&lt;BR /&gt;newmatch=\'$match\'&lt;BR /&gt;&lt;BR /&gt;echo $newmatch&lt;BR /&gt;'2 HARROW LANE'&lt;BR /&gt;&lt;BR /&gt;I get this though&lt;BR /&gt;&lt;BR /&gt;grep $newmatch &lt;FILENAME&gt;&lt;BR /&gt;&lt;BR /&gt;grep: can't open HARROW&lt;BR /&gt;grep: can't open LANE&lt;BR /&gt;grep: can't open '&lt;BR /&gt;&lt;BR /&gt;How can I resolve this &lt;BR /&gt;&lt;BR /&gt;Thanks in advance&lt;BR /&gt;&lt;BR /&gt;&lt;/FILENAME&gt;&lt;/FILENAME&gt;&lt;/FILENAME&gt;</description>
      <pubDate>Wed, 23 Jul 2003 00:21:19 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-help/m-p/3030574#M132501</guid>
      <dc:creator>Ian James_1</dc:creator>
      <dc:date>2003-07-23T00:21:19Z</dc:date>
    </item>
    <item>
      <title>Re: script help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-help/m-p/3030575#M132502</link>
      <description>Hi&lt;BR /&gt;&lt;BR /&gt;Put "" around the grep string as follows:&lt;BR /&gt;grep "$newmatch" &lt;FILENAME&gt;&lt;BR /&gt;&lt;BR /&gt;At the moment grep is trying to find 2 in the filenames HARROW and LANE.&lt;BR /&gt;&lt;BR /&gt;Cheers&lt;BR /&gt;Con&lt;/FILENAME&gt;</description>
      <pubDate>Wed, 23 Jul 2003 00:28:37 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-help/m-p/3030575#M132502</guid>
      <dc:creator>Con O'Kelly</dc:creator>
      <dc:date>2003-07-23T00:28:37Z</dc:date>
    </item>
    <item>
      <title>Re: script help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-help/m-p/3030576#M132503</link>
      <description>This might be a data problem.  Looks like you are getting some characters you don't expect in your file, before the data you want to grep for.  If there is a space in the file, thats interpreted by grep as the break between the first and second command line parameters.&lt;BR /&gt;&lt;BR /&gt;Hence your error.&lt;BR /&gt;&lt;BR /&gt;try this&lt;BR /&gt;&lt;BR /&gt;grep steve man&lt;BR /&gt;&lt;BR /&gt;you get&lt;BR /&gt;&lt;BR /&gt;grep: can't open man&lt;BR /&gt;&lt;BR /&gt;SEP</description>
      <pubDate>Wed, 23 Jul 2003 00:30:09 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-help/m-p/3030576#M132503</guid>
      <dc:creator>Steven E. Protter</dc:creator>
      <dc:date>2003-07-23T00:30:09Z</dc:date>
    </item>
    <item>
      <title>Re: script help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-help/m-p/3030577#M132504</link>
      <description>Try this instead:&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;&lt;BR /&gt;while read match&lt;BR /&gt;do&lt;BR /&gt;grep "$match" &lt;FILENAME&gt; &amp;gt; /tmp/totals &lt;BR /&gt;if [ $? = 0 ] &lt;BR /&gt;then &lt;BR /&gt;num=$(cat /tmp/totals) &lt;BR /&gt;echo "$match exists in &lt;FILENAME&gt; $num times" &lt;BR /&gt;fi &lt;BR /&gt;done &amp;lt; nomatch_add.dat&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;If you want to shorten it even more:&lt;BR /&gt;&lt;BR /&gt;while read match&lt;BR /&gt;do&lt;BR /&gt;num=$(grep "$match" &lt;FILENAME&gt; | grep -v grep | wc -l)&lt;BR /&gt;echo "$match exists in &lt;FILENAME&gt; $num times"&lt;BR /&gt;done &amp;lt; nomatch_add.dat&lt;/FILENAME&gt;&lt;/FILENAME&gt;&lt;/FILENAME&gt;&lt;/FILENAME&gt;</description>
      <pubDate>Wed, 23 Jul 2003 00:38:39 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-help/m-p/3030577#M132504</guid>
      <dc:creator>Patrick Wallek</dc:creator>
      <dc:date>2003-07-23T00:38:39Z</dc:date>
    </item>
    <item>
      <title>Re: script help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-help/m-p/3030578#M132505</link>
      <description>Thanks for the replies &lt;BR /&gt;&lt;BR /&gt;Stephen, &lt;BR /&gt;&lt;BR /&gt;Thats why I encased the 2 HARROW LANE in ' '&lt;BR /&gt;&lt;BR /&gt;Con&lt;BR /&gt;&lt;BR /&gt;I tried that but&lt;BR /&gt;&lt;BR /&gt;echo "$newmatch"&lt;BR /&gt;'2 HARROW ROAD'&lt;BR /&gt;&lt;BR /&gt;grep "$newmatch" &lt;FILENAME&gt;&lt;BR /&gt;&lt;BR /&gt;The above doesn't return anything, yet&lt;BR /&gt;&lt;BR /&gt;tail -1 &lt;FILENAME&gt;&lt;BR /&gt;&lt;BR /&gt;2 HARROW ROAD&lt;BR /&gt;&lt;BR /&gt;As it is trying to match '2 HARROW ROAD'&lt;BR /&gt;&lt;BR /&gt;I have therefore dropped the ' ' from the 2 HARROW ROAD&lt;BR /&gt;&lt;BR /&gt;Gone back to $match and simply encased the $match with " "&lt;BR /&gt;&lt;BR /&gt;grep "$match" &lt;FILENAME&gt;&lt;BR /&gt;&lt;BR /&gt;doh !!!!&lt;BR /&gt;&lt;BR /&gt;fundamentals me thinks&lt;BR /&gt;&lt;BR /&gt;Thanks for the replies&lt;BR /&gt;&lt;BR /&gt; &lt;BR /&gt;&lt;BR /&gt;&lt;/FILENAME&gt;&lt;/FILENAME&gt;&lt;/FILENAME&gt;</description>
      <pubDate>Wed, 23 Jul 2003 00:43:27 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-help/m-p/3030578#M132505</guid>
      <dc:creator>Ian James_1</dc:creator>
      <dc:date>2003-07-23T00:43:27Z</dc:date>
    </item>
    <item>
      <title>Re: script help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-help/m-p/3030579#M132506</link>
      <description>even shorter then&lt;BR /&gt;&lt;BR /&gt;while read match &lt;BR /&gt;do &lt;BR /&gt;num=$(grep "$match" &lt;FILENAME&gt; | grep -v grep | wc -l) &lt;BR /&gt;echo "$match exists in &lt;FILENAME&gt; $num times" &lt;BR /&gt;done &amp;lt; nomatch_add.dat &lt;BR /&gt;&lt;BR /&gt;would be&lt;BR /&gt;&lt;BR /&gt;while read match &lt;BR /&gt;do &lt;BR /&gt;num=$(grep -c "$match" &lt;FILENAME&gt;) &lt;BR /&gt;echo "$match exists in &lt;FILENAME&gt; $num times" &lt;BR /&gt;done &amp;lt; nomatch_add.dat&lt;/FILENAME&gt;&lt;/FILENAME&gt;&lt;/FILENAME&gt;&lt;/FILENAME&gt;</description>
      <pubDate>Wed, 23 Jul 2003 00:52:11 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-help/m-p/3030579#M132506</guid>
      <dc:creator>curt larson_1</dc:creator>
      <dc:date>2003-07-23T00:52:11Z</dc:date>
    </item>
    <item>
      <title>Re: script help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-help/m-p/3030580#M132507</link>
      <description>Hi&lt;BR /&gt;&lt;BR /&gt;Seems' I have another issue&lt;BR /&gt;&lt;BR /&gt;for match in `cat &lt;FILENAME&gt; | head -1`&lt;BR /&gt;do&lt;BR /&gt;echo $match&lt;BR /&gt;2 &lt;BR /&gt;HARROW&lt;BR /&gt;ROAD&lt;BR /&gt;&lt;BR /&gt;uhh!!!!&lt;BR /&gt;&lt;BR /&gt;cat &lt;FILENAME&gt; | head -1&lt;BR /&gt;2 HARROW ROAD&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Why is this ???&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Thanks in advance&lt;/FILENAME&gt;&lt;/FILENAME&gt;</description>
      <pubDate>Wed, 23 Jul 2003 01:00:58 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-help/m-p/3030580#M132507</guid>
      <dc:creator>Ian James_1</dc:creator>
      <dc:date>2003-07-23T01:00:58Z</dc:date>
    </item>
    <item>
      <title>Re: script help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-help/m-p/3030581#M132508</link>
      <description>Ho Hum&lt;BR /&gt;&lt;BR /&gt;Have ammended to&lt;BR /&gt;&lt;BR /&gt;cat &lt;FILENAME&gt; | while read match&lt;BR /&gt;&lt;BR /&gt;Seems to have done the trick&lt;BR /&gt;&lt;BR /&gt;Thanks everyone&lt;BR /&gt;&lt;BR /&gt;&lt;/FILENAME&gt;</description>
      <pubDate>Wed, 23 Jul 2003 01:06:08 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-help/m-p/3030581#M132508</guid>
      <dc:creator>Ian James_1</dc:creator>
      <dc:date>2003-07-23T01:06:08Z</dc:date>
    </item>
    <item>
      <title>Re: script help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-help/m-p/3030582#M132509</link>
      <description>and maybe a bit too terse&lt;BR /&gt;&lt;BR /&gt;file="nomatch_add.dat"&lt;BR /&gt;cat $file |&lt;BR /&gt;while read match &lt;BR /&gt;do &lt;BR /&gt;printf "$match exists in $file %d times\n" $(awk '/'"$match"'/ {t++;} END {print t;}' $file)&lt;BR /&gt;done</description>
      <pubDate>Wed, 23 Jul 2003 01:22:34 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-help/m-p/3030582#M132509</guid>
      <dc:creator>curt larson_1</dc:creator>
      <dc:date>2003-07-23T01:22:34Z</dc:date>
    </item>
  </channel>
</rss>

