<?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: File interrogation in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/file-interrogation/m-p/2913298#M933682</link>
    <description>Hi Cathy,&lt;BR /&gt;&lt;BR /&gt;Here is the modified script. Now do not run the individual commands as you may run into syntax issues. Just modify ABCXXXX.txt to match your filename and then run the script as it is. This will generate two files. ABCXXXX.txt.good and ABCXXXX.txt.bad.&lt;BR /&gt;&lt;BR /&gt;----copy below---&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/ksh                                                         &lt;BR /&gt;FILE=ABC1390.txt                                                       &lt;BR /&gt;MYNAME=$(echo $FILE|awk -F "." '{print $1}'|sed 's/ABC//g')            &lt;BR /&gt;                                                                       &lt;BR /&gt;awk -v STR="$MYNAME" -F "," '$2 == STR {print $0}' $FILE &amp;gt; $FILE.good  &lt;BR /&gt;awk -v STR="$MYNAME" -F "," '$2 != STR {print $0}' $FILE &amp;gt; $FILE.bad   &lt;BR /&gt;&lt;BR /&gt;----till here---&lt;BR /&gt;&lt;BR /&gt;-Sri</description>
    <pubDate>Wed, 26 Feb 2003 16:44:45 GMT</pubDate>
    <dc:creator>Sridhar Bhaskarla</dc:creator>
    <dc:date>2003-02-26T16:44:45Z</dc:date>
    <item>
      <title>File interrogation</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/file-interrogation/m-p/2913288#M933672</link>
      <description>Friends,&lt;BR /&gt;I have a file named&lt;BR /&gt;ABCxxxx.txt where xxxx changes but ABC remains constant.&lt;BR /&gt;&lt;BR /&gt;Within file ABCxxxx.txt I should have the following fixed layout:&lt;BR /&gt;aa,xxxx,bb,cccc   where the second column should always match the xxxx digits in the file name.&lt;BR /&gt;&lt;BR /&gt;What's the most efficient way to:&lt;BR /&gt;a) test the 'xxxx' in the filename against the 'xxxx' in every row of the file?  (I know how to get the xxxx out of the filename; it's the testing against the records I'm unsure of);&lt;BR /&gt;&lt;BR /&gt;b) How can I toss out those records that don't have a match?  &lt;BR /&gt;&lt;BR /&gt;Looking forward to your input!&lt;BR /&gt;Cath</description>
      <pubDate>Wed, 26 Feb 2003 00:49:24 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/file-interrogation/m-p/2913288#M933672</guid>
      <dc:creator>cbres00</dc:creator>
      <dc:date>2003-02-26T00:49:24Z</dc:date>
    </item>
    <item>
      <title>Re: File interrogation</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/file-interrogation/m-p/2913289#M933673</link>
      <description>One more thing:  in addition to tossing out records that don't match, I need to preserve the originals in a different file.&lt;BR /&gt;&lt;BR /&gt;CB</description>
      <pubDate>Wed, 26 Feb 2003 00:50:50 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/file-interrogation/m-p/2913289#M933673</guid>
      <dc:creator>cbres00</dc:creator>
      <dc:date>2003-02-26T00:50:50Z</dc:date>
    </item>
    <item>
      <title>Re: File interrogation</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/file-interrogation/m-p/2913290#M933674</link>
      <description>Hi Cath,&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/ksh&lt;BR /&gt;FILE=ABCXXXX.txt                                                     &lt;BR /&gt;MYNAME=$(echo $FILE|awk -F "." '{print $1}'|sed 's/ABC//g')          &lt;BR /&gt;                                                                     &lt;BR /&gt;awk -v STR="$MYNAME" -F "," '$2 == STR {print $0}' $FILE &amp;gt; $FILE.new &lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;-Sri&lt;BR /&gt;</description>
      <pubDate>Wed, 26 Feb 2003 01:04:05 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/file-interrogation/m-p/2913290#M933674</guid>
      <dc:creator>Sridhar Bhaskarla</dc:creator>
      <dc:date>2003-02-26T01:04:05Z</dc:date>
    </item>
    <item>
      <title>Re: File interrogation</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/file-interrogation/m-p/2913291#M933675</link>
      <description>Hi (Again),&lt;BR /&gt;&lt;BR /&gt;The above will create a new file called ABCXXXX.txt.new. You will still have the original file preserved. Replace ABCXXXX.txt with your file&lt;BR /&gt;&lt;BR /&gt;-Sri</description>
      <pubDate>Wed, 26 Feb 2003 01:06:25 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/file-interrogation/m-p/2913291#M933675</guid>
      <dc:creator>Sridhar Bhaskarla</dc:creator>
      <dc:date>2003-02-26T01:06:25Z</dc:date>
    </item>
    <item>
      <title>Re: File interrogation</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/file-interrogation/m-p/2913292#M933676</link>
      <description>I got the following error after executing the following:&lt;BR /&gt;awk -v STR=0139 -F , $2 == STR {print $0} ABC1390.txt&lt;BR /&gt;&lt;BR /&gt;"awk: syntax error near line 1"&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 26 Feb 2003 04:22:33 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/file-interrogation/m-p/2913292#M933676</guid>
      <dc:creator>cbres00</dc:creator>
      <dc:date>2003-02-26T04:22:33Z</dc:date>
    </item>
    <item>
      <title>Re: File interrogation</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/file-interrogation/m-p/2913293#M933677</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;You changed the syntax of the awk statement. Copy and Paste the above script into a file - call it script. Replace ABCXXXX.txt with ABC1390.txt and run the script. It will produce ABC1390.txt.new.&lt;BR /&gt;&lt;BR /&gt;Or run the command&lt;BR /&gt;&lt;BR /&gt;awk -F "," '$2 == "0139" {print $0}' ABC1390.txt&lt;BR /&gt;&lt;BR /&gt;will work for you if you have only one such file.&lt;BR /&gt;&lt;BR /&gt;-Sri&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 26 Feb 2003 04:48:52 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/file-interrogation/m-p/2913293#M933677</guid>
      <dc:creator>Sridhar Bhaskarla</dc:creator>
      <dc:date>2003-02-26T04:48:52Z</dc:date>
    </item>
    <item>
      <title>Re: File interrogation</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/file-interrogation/m-p/2913294#M933678</link>
      <description>Sri,&lt;BR /&gt;I figured out that my error was putting quotes around the comma separator.  When I do -F,  it works.&lt;BR /&gt;&lt;BR /&gt;So the errors go to $FILE.new.&lt;BR /&gt;Where would the good data land?  I need to end up with a file of good data and a file of bad data (if indeed there is bad data!)  And you KNOW there's bad data in this world!&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Cathy</description>
      <pubDate>Wed, 26 Feb 2003 05:20:26 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/file-interrogation/m-p/2913294#M933678</guid>
      <dc:creator>cbres00</dc:creator>
      <dc:date>2003-02-26T05:20:26Z</dc:date>
    </item>
    <item>
      <title>Re: File interrogation</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/file-interrogation/m-p/2913295#M933679</link>
      <description>I'm at a loss.  I set up four files, one of which has the incorrect xxxx in the second column.  I am not getting those records excluded into the new file.  &lt;BR /&gt;&lt;BR /&gt;Any other ideas?&lt;BR /&gt;</description>
      <pubDate>Wed, 26 Feb 2003 08:08:14 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/file-interrogation/m-p/2913295#M933679</guid>
      <dc:creator>cbres00</dc:creator>
      <dc:date>2003-02-26T08:08:14Z</dc:date>
    </item>
    <item>
      <title>Re: File interrogation</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/file-interrogation/m-p/2913296#M933680</link>
      <description>Hi Cathy,&lt;BR /&gt;could you please attach some authentic input containing  good and bad records?&lt;BR /&gt;&lt;BR /&gt;regards,&lt;BR /&gt;John K.</description>
      <pubDate>Wed, 26 Feb 2003 10:00:59 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/file-interrogation/m-p/2913296#M933680</guid>
      <dc:creator>john korterman</dc:creator>
      <dc:date>2003-02-26T10:00:59Z</dc:date>
    </item>
    <item>
      <title>Re: File interrogation</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/file-interrogation/m-p/2913297#M933681</link>
      <description>Good file:&lt;BR /&gt;File ABC0041.txt:&lt;BR /&gt;05,0041,20030226,15&lt;BR /&gt;&lt;BR /&gt;Bad file:&lt;BR /&gt;File ABC1346.txt&lt;BR /&gt;10,0139,20030226,15&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;I need to test the second column in the file make sure it matches the four digits in the file name. If the data's good it should go to one file; if it's bad it should go to another.&lt;BR /&gt;&lt;BR /&gt;Thanks!&lt;BR /&gt;Cathy</description>
      <pubDate>Wed, 26 Feb 2003 16:00:50 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/file-interrogation/m-p/2913297#M933681</guid>
      <dc:creator>cbres00</dc:creator>
      <dc:date>2003-02-26T16:00:50Z</dc:date>
    </item>
    <item>
      <title>Re: File interrogation</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/file-interrogation/m-p/2913298#M933682</link>
      <description>Hi Cathy,&lt;BR /&gt;&lt;BR /&gt;Here is the modified script. Now do not run the individual commands as you may run into syntax issues. Just modify ABCXXXX.txt to match your filename and then run the script as it is. This will generate two files. ABCXXXX.txt.good and ABCXXXX.txt.bad.&lt;BR /&gt;&lt;BR /&gt;----copy below---&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/ksh                                                         &lt;BR /&gt;FILE=ABC1390.txt                                                       &lt;BR /&gt;MYNAME=$(echo $FILE|awk -F "." '{print $1}'|sed 's/ABC//g')            &lt;BR /&gt;                                                                       &lt;BR /&gt;awk -v STR="$MYNAME" -F "," '$2 == STR {print $0}' $FILE &amp;gt; $FILE.good  &lt;BR /&gt;awk -v STR="$MYNAME" -F "," '$2 != STR {print $0}' $FILE &amp;gt; $FILE.bad   &lt;BR /&gt;&lt;BR /&gt;----till here---&lt;BR /&gt;&lt;BR /&gt;-Sri</description>
      <pubDate>Wed, 26 Feb 2003 16:44:45 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/file-interrogation/m-p/2913298#M933682</guid>
      <dc:creator>Sridhar Bhaskarla</dc:creator>
      <dc:date>2003-02-26T16:44:45Z</dc:date>
    </item>
    <item>
      <title>Re: File interrogation</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/file-interrogation/m-p/2913299#M933683</link>
      <description>Hi Sri.&lt;BR /&gt;I finally got it to work but only by using nawk rather than awk.&lt;BR /&gt;&lt;BR /&gt;Thanks for your valuable assistance.  Enjoy the points!&lt;BR /&gt;&lt;BR /&gt;Cathy</description>
      <pubDate>Wed, 26 Feb 2003 17:25:05 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/file-interrogation/m-p/2913299#M933683</guid>
      <dc:creator>cbres00</dc:creator>
      <dc:date>2003-02-26T17:25:05Z</dc:date>
    </item>
  </channel>
</rss>

