<?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 Shell Script in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/shell-script/m-p/4913515#M103733</link>
    <description>Can anybody give me the right syntax for a shell script?  I want to open the contents of one file, read through each line and grep for items in another file.  Do I use a for or while loop? Can anyone give me the correct syntax to use?&lt;BR /&gt;&lt;BR /&gt;e.g.&lt;BR /&gt;&lt;BR /&gt;cat file1 | while read line&lt;BR /&gt;do&lt;BR /&gt;???????&lt;BR /&gt;???????&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;thanks&lt;BR /&gt;&lt;BR /&gt;</description>
    <pubDate>Wed, 20 Jul 2005 02:32:08 GMT</pubDate>
    <dc:creator>ian walker_1</dc:creator>
    <dc:date>2005-07-20T02:32:08Z</dc:date>
    <item>
      <title>Shell Script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/shell-script/m-p/4913515#M103733</link>
      <description>Can anybody give me the right syntax for a shell script?  I want to open the contents of one file, read through each line and grep for items in another file.  Do I use a for or while loop? Can anyone give me the correct syntax to use?&lt;BR /&gt;&lt;BR /&gt;e.g.&lt;BR /&gt;&lt;BR /&gt;cat file1 | while read line&lt;BR /&gt;do&lt;BR /&gt;???????&lt;BR /&gt;???????&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;thanks&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 20 Jul 2005 02:32:08 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/shell-script/m-p/4913515#M103733</guid>
      <dc:creator>ian walker_1</dc:creator>
      <dc:date>2005-07-20T02:32:08Z</dc:date>
    </item>
    <item>
      <title>Re: Shell Script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/shell-script/m-p/4913516#M103734</link>
      <description>You can read file contents from a in serveral ways as,&lt;BR /&gt;&lt;BR /&gt; way 1&lt;BR /&gt;&lt;BR /&gt; touch newfile&lt;BR /&gt; cat file1 | while read line;&lt;BR /&gt; do&lt;BR /&gt;   echo $line | grep 'string' &amp;gt;&amp;gt; newfile&lt;BR /&gt; done&lt;BR /&gt;&lt;BR /&gt; way 2&lt;BR /&gt; (&lt;BR /&gt; while read line;&lt;BR /&gt; do&lt;BR /&gt;   echo $line | grep 'string'&lt;BR /&gt; done &amp;lt; inputfile&lt;BR /&gt; ) &amp;gt; newfile&lt;BR /&gt;&lt;BR /&gt; way 3:&lt;BR /&gt; &lt;BR /&gt; grep -E 'string1|string2|stringn' inputfile &amp;gt; newfile&lt;BR /&gt;&lt;BR /&gt;hth.&lt;BR /&gt;</description>
      <pubDate>Wed, 20 Jul 2005 02:57:38 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/shell-script/m-p/4913516#M103734</guid>
      <dc:creator>Muthukumar_5</dc:creator>
      <dc:date>2005-07-20T02:57:38Z</dc:date>
    </item>
    <item>
      <title>Re: Shell Script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/shell-script/m-p/4913517#M103735</link>
      <description>If you specify the exact requirement then we can give one line solution with perl or sed or awk or grep ;)&lt;BR /&gt;&lt;BR /&gt;hth.</description>
      <pubDate>Wed, 20 Jul 2005 02:58:29 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/shell-script/m-p/4913517#M103735</guid>
      <dc:creator>Muthukumar_5</dc:creator>
      <dc:date>2005-07-20T02:58:29Z</dc:date>
    </item>
    <item>
      <title>Re: Shell Script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/shell-script/m-p/4913518#M103736</link>
      <description>thanks for this but its not quite what i want.&lt;BR /&gt;Basically I have file1 which contains an output of a sw depot.  In file2 I have a list of software that I want to check is in file1... how do I do this?</description>
      <pubDate>Wed, 20 Jul 2005 03:40:00 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/shell-script/m-p/4913518#M103736</guid>
      <dc:creator>ian walker_1</dc:creator>
      <dc:date>2005-07-20T03:40:00Z</dc:date>
    </item>
    <item>
      <title>Re: Shell Script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/shell-script/m-p/4913519#M103737</link>
      <description>Hi,&lt;BR /&gt;I belive you would use the product number in the output from swlist to "grep" for the same product number in the second file.&lt;BR /&gt;&lt;BR /&gt;I suggest using "join" for this task. join matches fields from two files and print out selected fields from both of the files. The files must be sorted , using the matching field as sort key.&lt;BR /&gt;&lt;BR /&gt;For more details, see the man page for join.</description>
      <pubDate>Wed, 20 Jul 2005 04:24:39 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/shell-script/m-p/4913519#M103737</guid>
      <dc:creator>Leif Halvarsson_2</dc:creator>
      <dc:date>2005-07-20T04:24:39Z</dc:date>
    </item>
    <item>
      <title>Re: Shell Script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/shell-script/m-p/4913520#M103738</link>
      <description>ok lets be clear.&lt;BR /&gt;&lt;BR /&gt;file1 contains listing of software depot&lt;BR /&gt;file2 contains listing of software product numbers.&lt;BR /&gt;&lt;BR /&gt;I want to, using a loop?, in one go, check the contents of the first file, file1, using file2 as a sort of input or grep.  I know you can do this using a for/while loop, but what would be the right syntax???????&lt;BR /&gt;</description>
      <pubDate>Wed, 20 Jul 2005 05:01:30 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/shell-script/m-p/4913520#M103738</guid>
      <dc:creator>ian walker_1</dc:creator>
      <dc:date>2005-07-20T05:01:30Z</dc:date>
    </item>
    <item>
      <title>Re: Shell Script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/shell-script/m-p/4913521#M103739</link>
      <description>You don't need a loop.  If file2 contains the strings to search file1 for, then its this simple: &lt;BR /&gt;&lt;BR /&gt;grep -f file2 file1&lt;BR /&gt;&lt;BR /&gt;Beware of blank lines in file2.</description>
      <pubDate>Wed, 20 Jul 2005 05:32:03 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/shell-script/m-p/4913521#M103739</guid>
      <dc:creator>Steve Lewis</dc:creator>
      <dc:date>2005-07-20T05:32:03Z</dc:date>
    </item>
    <item>
      <title>Re: Shell Script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/shell-script/m-p/4913522#M103740</link>
      <description>Hey Ian&lt;BR /&gt;&lt;BR /&gt;try using diff -f &lt;FILE1&gt; &lt;FILE2&gt; &amp;gt; &lt;NEWFILE&gt; this will eek out wot you need&lt;BR /&gt;&lt;BR /&gt;Neil.&lt;/NEWFILE&gt;&lt;/FILE2&gt;&lt;/FILE1&gt;</description>
      <pubDate>Wed, 20 Jul 2005 05:58:06 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/shell-script/m-p/4913522#M103740</guid>
      <dc:creator>Neil Wilson_2</dc:creator>
      <dc:date>2005-07-20T05:58:06Z</dc:date>
    </item>
    <item>
      <title>Re: Shell Script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/shell-script/m-p/4913523#M103741</link>
      <description>thanks Steve and Neil.</description>
      <pubDate>Wed, 20 Jul 2005 06:00:02 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/shell-script/m-p/4913523#M103741</guid>
      <dc:creator>ian walker_1</dc:creator>
      <dc:date>2005-07-20T06:00:02Z</dc:date>
    </item>
    <item>
      <title>Re: Shell Script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/shell-script/m-p/4913524#M103742</link>
      <description>Hello Jan, I am under the impression that both files will have product number correct.&lt;BR /&gt;by product number use the following&lt;BR /&gt;&lt;BR /&gt;cat file2 | while read line;&lt;BR /&gt;do &lt;BR /&gt;## line is one field record product number ##&lt;BR /&gt;grep -q $line  file1&lt;BR /&gt;if [ $? -eq 0 ]; then  ## if found ##&lt;BR /&gt;echo "Product depot $line was fonund in the file1"&lt;BR /&gt;else  ## if not found ###&lt;BR /&gt;tput smso ## reverse video ##&lt;BR /&gt;echo "Product $line is not in file1 ..."&lt;BR /&gt;tput rmso ## normal video ##&lt;BR /&gt;fi&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;I hope this example helps&lt;BR /&gt;&lt;BR /&gt;done</description>
      <pubDate>Wed, 20 Jul 2005 06:04:42 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/shell-script/m-p/4913524#M103742</guid>
      <dc:creator>Juan M Leon</dc:creator>
      <dc:date>2005-07-20T06:04:42Z</dc:date>
    </item>
  </channel>
</rss>

