<?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 script in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/grep-script/m-p/2793693#M80424</link>
    <description>Had this thread open in my browser for an hour or so until i was able to write an answer.&lt;BR /&gt;&lt;BR /&gt;Harry was faster with exactly the same answer.&lt;BR /&gt;&lt;BR /&gt;Although i was second, i hope our answers will help.&lt;BR /&gt;&lt;BR /&gt;Regards Stefan</description>
    <pubDate>Mon, 26 Aug 2002 13:06:33 GMT</pubDate>
    <dc:creator>Stefan Schulz</dc:creator>
    <dc:date>2002-08-26T13:06:33Z</dc:date>
    <item>
      <title>grep script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/grep-script/m-p/2793683#M80414</link>
      <description>HI,&lt;BR /&gt;&lt;BR /&gt;I would like to grep patterns in "file_1.txt" which has the format below, in the file "original.txt" i.e I would  like to see if patterns in "file_1.txt" does exist in "original.txt"&lt;BR /&gt;&lt;BR /&gt;#cat file_1.txt&lt;BR /&gt;/fs10/my_design&lt;BR /&gt;/fs12/schematics&lt;BR /&gt;/fs36/optimization&lt;BR /&gt;/fs20/shark&lt;BR /&gt;&lt;BR /&gt;#cat original.txt&lt;BR /&gt;/fs10/my_design&lt;BR /&gt;/fs34/my_Circuits&lt;BR /&gt;/fs12/schematics&lt;BR /&gt;/fs15/layouts&lt;BR /&gt;&lt;BR /&gt;I wrote a script to check if the patterns in file_1.txt does actually exist in original.txt:&lt;BR /&gt;&lt;BR /&gt;#cat myscript.sh&lt;BR /&gt;for i in `cat file_1.txt`&lt;BR /&gt;do&lt;BR /&gt;   cat original.txt|grep $i|tee -a foundPatterns.txt&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;Unfortunately, it does not grep the patterns in "file_1.txt" out from the file "original.txt" although it does exist. &lt;BR /&gt;&lt;BR /&gt;However, when I did a:&lt;BR /&gt;#grep "/fs10/my_design" original.txt&lt;BR /&gt;/fs10/my_design&lt;BR /&gt;&lt;BR /&gt;it then prints the contents in "original.txt" which matches the pattern specified.&lt;BR /&gt;&lt;BR /&gt;Could someone show me how the script should have been written?&lt;BR /&gt;&lt;BR /&gt;Thanks.</description>
      <pubDate>Mon, 26 Aug 2002 06:50:06 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/grep-script/m-p/2793683#M80414</guid>
      <dc:creator>Chern Jian Leaw</dc:creator>
      <dc:date>2002-08-26T06:50:06Z</dc:date>
    </item>
    <item>
      <title>Re: grep script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/grep-script/m-p/2793684#M80415</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;a lazy solution :)&lt;BR /&gt;&lt;BR /&gt;cat original.txt file_1.txt | sort | uniq -d&lt;BR /&gt;&lt;BR /&gt;regards,&lt;BR /&gt;Thierry.</description>
      <pubDate>Mon, 26 Aug 2002 07:08:20 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/grep-script/m-p/2793684#M80415</guid>
      <dc:creator>Thierry Poels_1</dc:creator>
      <dc:date>2002-08-26T07:08:20Z</dc:date>
    </item>
    <item>
      <title>Re: grep script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/grep-script/m-p/2793685#M80416</link>
      <description>Hi&lt;BR /&gt;This should work (i called the files a and b in my test).&lt;BR /&gt;&lt;BR /&gt;# while read a&lt;BR /&gt;&amp;gt; do&lt;BR /&gt;&amp;gt; grep $a b&lt;BR /&gt;&amp;gt; done &lt;A&gt;/fs10/my_design &lt;BR /&gt;/fs12/schematics &lt;BR /&gt;&lt;/A&gt;</description>
      <pubDate>Mon, 26 Aug 2002 07:10:33 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/grep-script/m-p/2793685#M80416</guid>
      <dc:creator>Leif Halvarsson_2</dc:creator>
      <dc:date>2002-08-26T07:10:33Z</dc:date>
    </item>
    <item>
      <title>Re: grep script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/grep-script/m-p/2793686#M80417</link>
      <description>Hi,&lt;BR /&gt;I did this ...&lt;BR /&gt;$more myscript.sh&lt;BR /&gt;for i in $(cat file_1.txt)&lt;BR /&gt;do&lt;BR /&gt;cat original.txt | grep $i | tee -a foundPatterns.txt&lt;BR /&gt;done&lt;BR /&gt;$./myscript.sh&lt;BR /&gt;/fs10/my_design&lt;BR /&gt;/fs12/schematics&lt;BR /&gt;$more foundPatterns.txt&lt;BR /&gt;/fs10/my_design&lt;BR /&gt;/fs12/schematics&lt;BR /&gt;&lt;BR /&gt;... which is - imho - exactly what it should be ... or am I missing the point here ?&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Tom</description>
      <pubDate>Mon, 26 Aug 2002 07:10:53 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/grep-script/m-p/2793686#M80417</guid>
      <dc:creator>Tom Geudens</dc:creator>
      <dc:date>2002-08-26T07:10:53Z</dc:date>
    </item>
    <item>
      <title>Re: grep script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/grep-script/m-p/2793687#M80418</link>
      <description>Tom,&lt;BR /&gt;I did exactly what you did i.e:&lt;BR /&gt;#!/bin/sh&lt;BR /&gt;&lt;BR /&gt;for i in $(cat file_1.txt)&lt;BR /&gt;do &lt;BR /&gt;   cat original.txt|grep $i|tee -a foundPatterns.txt &lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;but I'm still unable to find the patterns in original.txt which matches those in file_1.txt.&lt;BR /&gt;&lt;BR /&gt;Could you help me out?&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;CJ</description>
      <pubDate>Mon, 26 Aug 2002 07:37:43 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/grep-script/m-p/2793687#M80418</guid>
      <dc:creator>Chern Jian Leaw</dc:creator>
      <dc:date>2002-08-26T07:37:43Z</dc:date>
    </item>
    <item>
      <title>Re: grep script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/grep-script/m-p/2793688#M80419</link>
      <description>&lt;BR /&gt;--------------------------&lt;BR /&gt;for i in `cat /tmp/file.txt`&lt;BR /&gt;do&lt;BR /&gt;grep "$i" /tmp/original.txt&lt;BR /&gt;done&lt;BR /&gt;--------------------------&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Thanks</description>
      <pubDate>Mon, 26 Aug 2002 07:45:42 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/grep-script/m-p/2793688#M80419</guid>
      <dc:creator>T G Manikandan</dc:creator>
      <dc:date>2002-08-26T07:45:42Z</dc:date>
    </item>
    <item>
      <title>Re: grep script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/grep-script/m-p/2793689#M80420</link>
      <description>Hi,&lt;BR /&gt;Very strange.&lt;BR /&gt;I altered the script just a little, but basically it SHOULD work. I attached myscript. Can you execute it ? Can you also execute with "sh -x myscript.sh" and post the output ?&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Tom</description>
      <pubDate>Mon, 26 Aug 2002 07:55:42 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/grep-script/m-p/2793689#M80420</guid>
      <dc:creator>Tom Geudens</dc:creator>
      <dc:date>2002-08-26T07:55:42Z</dc:date>
    </item>
    <item>
      <title>Re: grep script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/grep-script/m-p/2793690#M80421</link>
      <description>&lt;BR /&gt;SIMPLE:&lt;BR /&gt;&lt;BR /&gt;# grep -f file_1.txt original.txt&lt;BR /&gt;/fs10/my_design&lt;BR /&gt;/fs12/schematics&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;# cat file_1.txt                 &lt;BR /&gt;/fs10/my_design&lt;BR /&gt;/fs12/schematics&lt;BR /&gt;/fs36/optimization&lt;BR /&gt;/fs20/shark &lt;BR /&gt;# cat original.txt               &lt;BR /&gt;/fs10/my_design&lt;BR /&gt;/fs34/my_Circuits&lt;BR /&gt;/fs12/schematics&lt;BR /&gt;/fs15/layouts &lt;BR /&gt;# &lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;live free or die&lt;BR /&gt;harry</description>
      <pubDate>Mon, 26 Aug 2002 12:17:57 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/grep-script/m-p/2793690#M80421</guid>
      <dc:creator>harry d brown jr</dc:creator>
      <dc:date>2002-08-26T12:17:57Z</dc:date>
    </item>
    <item>
      <title>Re: grep script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/grep-script/m-p/2793691#M80422</link>
      <description>Try "cat -e" on your pattern file to be sure that you do not have any "hidden" characters or trailing spaces.&lt;BR /&gt;These could prevent a match.&lt;BR /&gt;&lt;BR /&gt;Rich</description>
      <pubDate>Mon, 26 Aug 2002 12:18:15 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/grep-script/m-p/2793691#M80422</guid>
      <dc:creator>Rich Wright</dc:creator>
      <dc:date>2002-08-26T12:18:15Z</dc:date>
    </item>
    <item>
      <title>Re: grep script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/grep-script/m-p/2793692#M80423</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;i think the grep command will do what you want. Try the follwing:&lt;BR /&gt;&lt;BR /&gt;grep -f file_1.txt original.txt&lt;BR /&gt;&lt;BR /&gt;This should give you all entries from file_1.txt which appear in original.txt.&lt;BR /&gt;&lt;BR /&gt;If needed you could add the -x option for eXact matches.&lt;BR /&gt;&lt;BR /&gt;Hope this helps.&lt;BR /&gt;&lt;BR /&gt;Stefan</description>
      <pubDate>Mon, 26 Aug 2002 13:03:07 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/grep-script/m-p/2793692#M80423</guid>
      <dc:creator>Stefan Schulz</dc:creator>
      <dc:date>2002-08-26T13:03:07Z</dc:date>
    </item>
    <item>
      <title>Re: grep script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/grep-script/m-p/2793693#M80424</link>
      <description>Had this thread open in my browser for an hour or so until i was able to write an answer.&lt;BR /&gt;&lt;BR /&gt;Harry was faster with exactly the same answer.&lt;BR /&gt;&lt;BR /&gt;Although i was second, i hope our answers will help.&lt;BR /&gt;&lt;BR /&gt;Regards Stefan</description>
      <pubDate>Mon, 26 Aug 2002 13:06:33 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/grep-script/m-p/2793693#M80424</guid>
      <dc:creator>Stefan Schulz</dc:creator>
      <dc:date>2002-08-26T13:06:33Z</dc:date>
    </item>
    <item>
      <title>Re: grep script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/grep-script/m-p/2793694#M80425</link>
      <description>Hi&lt;BR /&gt;&lt;BR /&gt;I only read the first few replys.  I think the problem with using grep is that there are meta characters in the grep (like - / $ spaces etc).&lt;BR /&gt;&lt;BR /&gt;You might like to alter you script subtly and do&lt;BR /&gt;&lt;BR /&gt;#cat myscript.sh &lt;BR /&gt;for i in `cat file_1.txt` &lt;BR /&gt;do &lt;BR /&gt;grep "$i" original.txt|tee -a foundPatterns.txt &lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;Regards&lt;BR /&gt;&lt;BR /&gt;Tim&lt;BR /&gt;</description>
      <pubDate>Mon, 26 Aug 2002 14:22:04 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/grep-script/m-p/2793694#M80425</guid>
      <dc:creator>Tim D Fulford</dc:creator>
      <dc:date>2002-08-26T14:22:04Z</dc:date>
    </item>
  </channel>
</rss>

