<?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: Need some scripting assistance.... in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/need-some-scripting-assistance/m-p/4013903#M299149</link>
    <description>Looks like this is all I have to do...&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;#!/bin/sh&lt;BR /&gt;for SN in `cat /opt/home/johnsonr/scripts/file`&lt;BR /&gt;do&lt;BR /&gt; grep $SN /opt/CSCOpx/htdocs/reports/NC*.xml &amp;gt;&amp;gt; /tmp/SNFile&lt;BR /&gt;&lt;BR /&gt;done</description>
    <pubDate>Tue, 05 Jun 2007 18:54:25 GMT</pubDate>
    <dc:creator>Rob Johnson_3</dc:creator>
    <dc:date>2007-06-05T18:54:25Z</dc:date>
    <item>
      <title>Need some scripting assistance....</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/need-some-scripting-assistance/m-p/4013902#M299148</link>
      <description>Situation:&lt;BR /&gt;I have a text file with 949 serial numbers in this format:&lt;BR /&gt; johnsonr@nmscrme01 &amp;gt;  cat file&lt;BR /&gt; 28991175&lt;BR /&gt; 28991216&lt;BR /&gt; 29591918&lt;BR /&gt; ...&lt;BR /&gt; ...&lt;BR /&gt; ...&lt;BR /&gt; johnsonr@nmscrme01 &amp;gt;&lt;BR /&gt;&lt;BR /&gt;What I need to do is search this file against several XML files to see if there are any matches and if so, what file is the match in?&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Here's a script that basically says:&lt;BR /&gt;for each serial number in file, do a grep on several NC*.xml files in a certain directory.&lt;BR /&gt;However, I would like to make it where the output is redirected to another file say in the /tmp directory.  Can someone help me out?&lt;BR /&gt;      ---Here's the script---&lt;BR /&gt; #!/bin/sh&lt;BR /&gt; for SN in `cat /opt/home/johnsonr/scripts/file`&lt;BR /&gt; do&lt;BR /&gt;   grep $SN /opt/CSCOpx/htdocs/reports/NC*.xml&lt;BR /&gt; done&lt;BR /&gt;&lt;BR /&gt;Here's output from the script which is fine.&lt;BR /&gt;&lt;BR /&gt;  johnsonr@nmscrme01 &amp;gt;  ./snsearch.sh &lt;BR /&gt;  /opt/CSCOpx/htdocs/reports/NC-DONPortCount.xml:&lt;SERIALNUMBER&gt;29769187&lt;/SERIALNUMBER&gt;&lt;BR /&gt;  /opt/CSCOpx/htdocs/reports/NC-DONPortCount.xml:&lt;SERIALNUMBER&gt;29769188&lt;/SERIALNUMBER&gt;&lt;BR /&gt;  /opt/CSCOpx/htdocs/reports/NC-DONPortCount.xml:&lt;SERIALNUMBER&gt;30959474&lt;/SERIALNUMBER&gt;&lt;BR /&gt;  johnsonr@nmscrme01 &amp;gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;I was thinking something along these lines but need assistance...&lt;BR /&gt;&lt;BR /&gt;#!/bin/sh&lt;BR /&gt;for SN in `cat /opt/home/johnsonr/scripts/file`&lt;BR /&gt;do&lt;BR /&gt; grep $SN /opt/CSCOpx/htdocs/reports/NC*.xml&lt;BR /&gt;&lt;BR /&gt;if [ $? -gt 0 ]                       -------this is the section i need the help in&lt;BR /&gt; then                                 -------this is the section i need the help in&lt;BR /&gt;        echo $results &amp;gt;&amp;gt; /tmp/SNFile  -------this is the section i need the help in&lt;BR /&gt;fi                                    -------this is the section i need the help in&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;Thanks in advance to all you scripters out there!</description>
      <pubDate>Tue, 05 Jun 2007 17:55:15 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/need-some-scripting-assistance/m-p/4013902#M299148</guid>
      <dc:creator>Rob Johnson_3</dc:creator>
      <dc:date>2007-06-05T17:55:15Z</dc:date>
    </item>
    <item>
      <title>Re: Need some scripting assistance....</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/need-some-scripting-assistance/m-p/4013903#M299149</link>
      <description>Looks like this is all I have to do...&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;#!/bin/sh&lt;BR /&gt;for SN in `cat /opt/home/johnsonr/scripts/file`&lt;BR /&gt;do&lt;BR /&gt; grep $SN /opt/CSCOpx/htdocs/reports/NC*.xml &amp;gt;&amp;gt; /tmp/SNFile&lt;BR /&gt;&lt;BR /&gt;done</description>
      <pubDate>Tue, 05 Jun 2007 18:54:25 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/need-some-scripting-assistance/m-p/4013903#M299149</guid>
      <dc:creator>Rob Johnson_3</dc:creator>
      <dc:date>2007-06-05T18:54:25Z</dc:date>
    </item>
    <item>
      <title>Re: Need some scripting assistance....</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/need-some-scripting-assistance/m-p/4013904#M299150</link>
      <description>&lt;!--!*#--&gt;Hi Rob:&lt;BR /&gt;&lt;BR /&gt;You can do something like this:&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;set -u&lt;BR /&gt;typeset TOKENS=/opt/home/johnsonr/scripts/file&lt;BR /&gt;typeset OUTPUT=/tmp/SNFile&lt;BR /&gt;rm "${OUTPUT}"&lt;BR /&gt;for SN in `cat ${TOKENS}`&lt;BR /&gt;do&lt;BR /&gt;    grep ${SN} /opt/CSCOpx/htdocs/reports/NC*.xml /dev/null &amp;gt;&amp;gt; ${OUTPUT}&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;...By adding '/dev/null' to the file arguments to 'grep' the name of any file that constains a match is reported along with the match.&lt;BR /&gt;&lt;BR /&gt;In keeping with the rule that "silence is golden", 'grep' will not output anything if there isn't at least one match.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Tue, 05 Jun 2007 18:55:44 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/need-some-scripting-assistance/m-p/4013904#M299150</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2007-06-05T18:55:44Z</dc:date>
    </item>
    <item>
      <title>Re: Need some scripting assistance....</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/need-some-scripting-assistance/m-p/4013905#M299151</link>
      <description>if all you want is for the exact output of your existing script to go to a file, you don't need to modify the script. Just redirect it's output.&lt;BR /&gt;&lt;BR /&gt;johnsonr@nmscrme01 &amp;gt; ./snsearch.sh &amp;gt;/tmp/SNFile &lt;BR /&gt;</description>
      <pubDate>Tue, 05 Jun 2007 18:58:33 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/need-some-scripting-assistance/m-p/4013905#M299151</guid>
      <dc:creator>John Kittel</dc:creator>
      <dc:date>2007-06-05T18:58:33Z</dc:date>
    </item>
    <item>
      <title>Re: Need some scripting assistance....</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/need-some-scripting-assistance/m-p/4013906#M299152</link>
      <description>Note there is no reason to use a for-loop unless you need to test on the serial number :&lt;BR /&gt;&lt;BR /&gt;$ grep -f /opt/home/johnsonr/scripts/file \&lt;BR /&gt;/opt/CSCOpx/htdocs/reports/NC*.xml /dev/null&lt;BR /&gt;&lt;BR /&gt;If you only want the filename of the match, but not number you can add -l.&lt;BR /&gt;&lt;BR /&gt;If you don't want to find your serial numbers in the middle of strings, you would use -w.</description>
      <pubDate>Tue, 05 Jun 2007 22:41:59 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/need-some-scripting-assistance/m-p/4013906#M299152</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2007-06-05T22:41:59Z</dc:date>
    </item>
  </channel>
</rss>

