<?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: Finding and correcting curropt file lines in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/finding-and-correcting-curropt-file-lines/m-p/3054137#M137218</link>
    <description>Roland's answer might work, with proper " !! :)&lt;BR /&gt;&lt;BR /&gt;cat yourFile|&lt;BR /&gt;awk '&lt;BR /&gt;#assume the first line starts correct&lt;BR /&gt;#print it without a newline&lt;BR /&gt;NR == 1 {printf("%s",$0);next;}&lt;BR /&gt;# if the line match our pattern&lt;BR /&gt;# apply the newline and&lt;BR /&gt;#print it without a newline&lt;BR /&gt;/^HDR/ {printf("\n%s",$0);next;}&lt;BR /&gt;/^POL/ {printf("\n%s",$0);next;}&lt;BR /&gt;/^OBJ/ {printf("\n%s",$0);next;}&lt;BR /&gt;# doesn't match one of out patterns&lt;BR /&gt;# print the line, joining it to the&lt;BR /&gt;# previous line&lt;BR /&gt;{printf("%s",$0);}&lt;BR /&gt;# apply an ending newline if necessary&lt;BR /&gt;END {printf("\n");}&lt;BR /&gt;'&amp;gt; newfile &lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;One day or the other i will study awk seriusly....&lt;BR /&gt;&lt;BR /&gt;   Massimo</description>
    <pubDate>Fri, 22 Aug 2003 09:24:20 GMT</pubDate>
    <dc:creator>Massimo Bianchi</dc:creator>
    <dc:date>2003-08-22T09:24:20Z</dc:date>
    <item>
      <title>Finding and correcting curropt file lines</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/finding-and-correcting-curropt-file-lines/m-p/3054128#M137209</link>
      <description>I have a file where each line starts with one of the following strings; &lt;BR /&gt;&lt;BR /&gt;HDR&lt;BR /&gt;POL &lt;BR /&gt;OBJ&lt;BR /&gt;&lt;BR /&gt;I have a script which searches the file and errors if one of the lines has is corrupt. The scripts run as follows &lt;BR /&gt;&lt;BR /&gt;cat &lt;FILE&gt; | while read line                                    &lt;BR /&gt;do                                             grep -n -e "^HDR" -e "^POL" -e "^OBJ" -v &amp;gt; err_log.txt&lt;BR /&gt;done                                           &lt;BR /&gt;&lt;BR /&gt;I then manually edit the script at the lines reported in the err_log.txt (if any exist)&lt;BR /&gt;&lt;BR /&gt;Is there any way I can get the script to perform the corrections for me? any help appreciated &lt;BR /&gt;&lt;BR /&gt;Declan&lt;/FILE&gt;</description>
      <pubDate>Thu, 21 Aug 2003 15:37:27 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/finding-and-correcting-curropt-file-lines/m-p/3054128#M137209</guid>
      <dc:creator>Declan Heerey</dc:creator>
      <dc:date>2003-08-21T15:37:27Z</dc:date>
    </item>
    <item>
      <title>Re: Finding and correcting curropt file lines</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/finding-and-correcting-curropt-file-lines/m-p/3054129#M137210</link>
      <description>Hi,&lt;BR /&gt;i think that you have no luck, because corruption can have different method for appearing.&lt;BR /&gt;&lt;BR /&gt;If you know exactly what kind of corruption can be, there are chances.&lt;BR /&gt;&lt;BR /&gt;Other way, if you want to tear away the offending lines, you can use a nice grep like your, without "-v", redirecting output to a file, but i suspect some missing things.&lt;BR /&gt;&lt;BR /&gt;Any more hints from you regarding the kind of corruption ?&lt;BR /&gt;&lt;BR /&gt;  Massimo</description>
      <pubDate>Thu, 21 Aug 2003 15:41:12 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/finding-and-correcting-curropt-file-lines/m-p/3054129#M137210</guid>
      <dc:creator>Massimo Bianchi</dc:creator>
      <dc:date>2003-08-21T15:41:12Z</dc:date>
    </item>
    <item>
      <title>Re: Finding and correcting curropt file lines</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/finding-and-correcting-curropt-file-lines/m-p/3054130#M137211</link>
      <description>Declan,&lt;BR /&gt;  You havnt said what to replace with.  Corruption is random.  If you want you can redirect all the valid lines to another file but you may be missing the corrupted lines which needs your manual attention.&lt;BR /&gt;&lt;BR /&gt;-Umapathy&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 21 Aug 2003 15:44:54 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/finding-and-correcting-curropt-file-lines/m-p/3054130#M137211</guid>
      <dc:creator>Umapathy S</dc:creator>
      <dc:date>2003-08-21T15:44:54Z</dc:date>
    </item>
    <item>
      <title>Re: Finding and correcting curropt file lines</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/finding-and-correcting-curropt-file-lines/m-p/3054131#M137212</link>
      <description>Apologies i should have explained; corruption normally takes place when a line breaks before finishing and so begins another line i.e &lt;BR /&gt;&lt;BR /&gt;HDR &lt;LINE and="" message="" text=""&gt;&lt;/LINE&gt;more text&amp;gt; &lt;BR /&gt;POL&lt;BR /&gt;OBJ&lt;BR /&gt;&lt;BR /&gt;I then go to offending line (end of HDR line) and hit Ctrl J</description>
      <pubDate>Thu, 21 Aug 2003 15:47:02 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/finding-and-correcting-curropt-file-lines/m-p/3054131#M137212</guid>
      <dc:creator>Declan Heerey</dc:creator>
      <dc:date>2003-08-21T15:47:02Z</dc:date>
    </item>
    <item>
      <title>Re: Finding and correcting curropt file lines</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/finding-and-correcting-curropt-file-lines/m-p/3054132#M137213</link>
      <description>Hello!&lt;BR /&gt;&lt;BR /&gt;I guess your 'grep' is already doing the trick if you remove  -n and -v.&lt;BR /&gt;&lt;BR /&gt;Or use this shorter solution:&lt;BR /&gt;&lt;BR /&gt;grep -E "^(HDR|POL|OBJ)" &lt;BROKEN.TXT&gt;repaired.txt&lt;BR /&gt;&lt;BR /&gt;Erik&lt;/BROKEN.TXT&gt;</description>
      <pubDate>Thu, 21 Aug 2003 15:50:55 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/finding-and-correcting-curropt-file-lines/m-p/3054132#M137213</guid>
      <dc:creator>Erik Heckers</dc:creator>
      <dc:date>2003-08-21T15:50:55Z</dc:date>
    </item>
    <item>
      <title>Re: Finding and correcting curropt file lines</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/finding-and-correcting-curropt-file-lines/m-p/3054133#M137214</link>
      <description>&lt;BR /&gt;&lt;BR /&gt;Hi&lt;BR /&gt;use sed command for delete/change this lines.&lt;BR /&gt;&lt;BR /&gt;To</description>
      <pubDate>Thu, 21 Aug 2003 15:51:03 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/finding-and-correcting-curropt-file-lines/m-p/3054133#M137214</guid>
      <dc:creator>TOMAS BERNABEU</dc:creator>
      <dc:date>2003-08-21T15:51:03Z</dc:date>
    </item>
    <item>
      <title>Re: Finding and correcting curropt file lines</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/finding-and-correcting-curropt-file-lines/m-p/3054134#M137215</link>
      <description>a start would be&lt;BR /&gt;&lt;BR /&gt;cat $yourFile |&lt;BR /&gt;while read line&lt;BR /&gt;do&lt;BR /&gt;case $line in&lt;BR /&gt;HDR*) if corrupt ;then&lt;BR /&gt;         fix&lt;BR /&gt;      fi&lt;BR /&gt;      print fixedLine;;&lt;BR /&gt;POL*) if corrupt ;then&lt;BR /&gt;         fix&lt;BR /&gt;      fi&lt;BR /&gt;      print fixedLine;;&lt;BR /&gt;OBJ*) if corrupt ;then&lt;BR /&gt;         fix&lt;BR /&gt;      fi&lt;BR /&gt;      print fixedLine;;&lt;BR /&gt;*) print $line;;&lt;BR /&gt;done &amp;gt; newFile&lt;BR /&gt;&lt;BR /&gt;#check your fixes or&lt;BR /&gt;mv newFile yourFile&lt;BR /&gt;&lt;BR /&gt;your have to put in how to test for corruption&lt;BR /&gt;and what the fix would be</description>
      <pubDate>Thu, 21 Aug 2003 15:51:33 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/finding-and-correcting-curropt-file-lines/m-p/3054134#M137215</guid>
      <dc:creator>curt larson_1</dc:creator>
      <dc:date>2003-08-21T15:51:33Z</dc:date>
    </item>
    <item>
      <title>Re: Finding and correcting curropt file lines</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/finding-and-correcting-curropt-file-lines/m-p/3054135#M137216</link>
      <description>you could try something like this&lt;BR /&gt;&lt;BR /&gt;cat yourFile|&lt;BR /&gt;awk '&lt;BR /&gt;#assume the first line starts correct&lt;BR /&gt;#print it without a newline&lt;BR /&gt;NR == 1 {printf("%s",$0);next;}&lt;BR /&gt;# if the line match our pattern&lt;BR /&gt;# apply the newline and &lt;BR /&gt;#print it without a newline&lt;BR /&gt;/^HDR/ {printf("\n%s,$0);next;}&lt;BR /&gt;/^POL/ {printf("\n%s,$0);next;}&lt;BR /&gt;/^OBJ/ {printf("\n%s,$0);next;}&lt;BR /&gt;# doesn't match one of out patterns&lt;BR /&gt;# print the line, joining it to the&lt;BR /&gt;# previous line&lt;BR /&gt;{printf("%s,$0);}&lt;BR /&gt;# apply an ending newline if necessary&lt;BR /&gt;END {printf("\n");}&lt;BR /&gt;'&amp;gt; newfile&lt;BR /&gt;&lt;BR /&gt;you can apply spacing on the join and ending newline as desired</description>
      <pubDate>Thu, 21 Aug 2003 16:18:34 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/finding-and-correcting-curropt-file-lines/m-p/3054135#M137216</guid>
      <dc:creator>curt larson_1</dc:creator>
      <dc:date>2003-08-21T16:18:34Z</dc:date>
    </item>
    <item>
      <title>Re: Finding and correcting curropt file lines</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/finding-and-correcting-curropt-file-lines/m-p/3054136#M137217</link>
      <description>Curt, that looks like the solution i need, however when i run the script against the file in question i get the following error messages; &lt;BR /&gt;&lt;BR /&gt; awk: The string                                                        &lt;BR /&gt;%s,$0);ne cannot contain a newline character.                           &lt;BR /&gt;The source line is 13.                                 &lt;BR /&gt; The error context is                                                   &lt;BR /&gt;                /^HDR/ {printf("\n%s,$0);next;}  &amp;gt;&amp;gt;&amp;gt;                    &lt;BR /&gt; &amp;lt;&amp;lt;&amp;lt;                                                                    &lt;BR /&gt; syntax error The source line is 14.                                    &lt;BR /&gt; awk: The statement cannot be correctly parsed.                         &lt;BR /&gt; The source line is 14.                                                 &lt;BR /&gt;        awk: There are 3 missing } characters.                          &lt;BR /&gt;        awk: There are 3 missing ) characters.                          &lt;BR /&gt;./test_and_fix[15]: Syntax error at line 15 : `(' is not expected.      &lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Any ideas?</description>
      <pubDate>Fri, 22 Aug 2003 07:44:54 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/finding-and-correcting-curropt-file-lines/m-p/3054136#M137217</guid>
      <dc:creator>Declan Heerey</dc:creator>
      <dc:date>2003-08-22T07:44:54Z</dc:date>
    </item>
    <item>
      <title>Re: Finding and correcting curropt file lines</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/finding-and-correcting-curropt-file-lines/m-p/3054137#M137218</link>
      <description>Roland's answer might work, with proper " !! :)&lt;BR /&gt;&lt;BR /&gt;cat yourFile|&lt;BR /&gt;awk '&lt;BR /&gt;#assume the first line starts correct&lt;BR /&gt;#print it without a newline&lt;BR /&gt;NR == 1 {printf("%s",$0);next;}&lt;BR /&gt;# if the line match our pattern&lt;BR /&gt;# apply the newline and&lt;BR /&gt;#print it without a newline&lt;BR /&gt;/^HDR/ {printf("\n%s",$0);next;}&lt;BR /&gt;/^POL/ {printf("\n%s",$0);next;}&lt;BR /&gt;/^OBJ/ {printf("\n%s",$0);next;}&lt;BR /&gt;# doesn't match one of out patterns&lt;BR /&gt;# print the line, joining it to the&lt;BR /&gt;# previous line&lt;BR /&gt;{printf("%s",$0);}&lt;BR /&gt;# apply an ending newline if necessary&lt;BR /&gt;END {printf("\n");}&lt;BR /&gt;'&amp;gt; newfile &lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;One day or the other i will study awk seriusly....&lt;BR /&gt;&lt;BR /&gt;   Massimo</description>
      <pubDate>Fri, 22 Aug 2003 09:24:20 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/finding-and-correcting-curropt-file-lines/m-p/3054137#M137218</guid>
      <dc:creator>Massimo Bianchi</dc:creator>
      <dc:date>2003-08-22T09:24:20Z</dc:date>
    </item>
    <item>
      <title>Re: Finding and correcting curropt file lines</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/finding-and-correcting-curropt-file-lines/m-p/3054138#M137219</link>
      <description>One day i will do the same, until then any additional help would be appreciated. With the correct ""'s i get the following error;&lt;BR /&gt;&lt;BR /&gt;awk: Cannot find or open file match.                              &lt;BR /&gt;The source line number is 17.                                    &lt;BR /&gt;./test_and_fix[15]: Syntax error at line 15 : `(' is not expected.</description>
      <pubDate>Fri, 22 Aug 2003 09:38:40 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/finding-and-correcting-curropt-file-lines/m-p/3054138#M137219</guid>
      <dc:creator>Declan Heerey</dc:creator>
      <dc:date>2003-08-22T09:38:40Z</dc:date>
    </item>
    <item>
      <title>Re: Finding and correcting curropt file lines</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/finding-and-correcting-curropt-file-lines/m-p/3054139#M137220</link>
      <description>Hello Declan,&lt;BR /&gt;&lt;BR /&gt;The following perl script will do what you expect :&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/perl&lt;BR /&gt;&lt;BR /&gt;# read the file and place it in a list&lt;BR /&gt;while (&amp;lt;&amp;gt;) {&lt;BR /&gt;        chomp;&lt;BR /&gt;        push(@liste,$_);&lt;BR /&gt;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;# print first line assumed ok&lt;BR /&gt;$line = shift(@liste);&lt;BR /&gt;print $line;&lt;BR /&gt;&lt;BR /&gt;# handle other lines&lt;BR /&gt;foreach $line (@liste) {&lt;BR /&gt;        # print a newline if the line did not match the patterns&lt;BR /&gt;        print "\n" if ($line =~ /^HDR/ || $line =~ /^POL/ || $line =~ /^OBJ/);&lt;BR /&gt;        print $line;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;# print trailing newline&lt;BR /&gt;print "\n"&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Save the script in a file xx.pl (eventually change the first line to match the path of a perl interpreter on your system), make the xx.pl file executable and use :&lt;BR /&gt;&lt;BR /&gt;cat &lt;FILE&gt; | xx.pl &amp;gt; file.out&lt;BR /&gt;&lt;BR /&gt;&lt;/FILE&gt;</description>
      <pubDate>Fri, 22 Aug 2003 09:52:45 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/finding-and-correcting-curropt-file-lines/m-p/3054139#M137220</guid>
      <dc:creator>Charles G.</dc:creator>
      <dc:date>2003-08-22T09:52:45Z</dc:date>
    </item>
    <item>
      <title>Re: Finding and correcting curropt file lines</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/finding-and-correcting-curropt-file-lines/m-p/3054140#M137221</link>
      <description>Charles, you're a star, that perl script works a treat!!! thanks for all the help guys, much appreciated. &lt;BR /&gt;&lt;BR /&gt;I'm going to get onto my boss and sort out a perl course! &lt;BR /&gt;&lt;BR /&gt;Great stuff and thanks again! I'll be able to relax over the weekend &lt;BR /&gt;&lt;BR /&gt;Have a good one &lt;BR /&gt;&lt;BR /&gt;Declan</description>
      <pubDate>Fri, 22 Aug 2003 10:49:56 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/finding-and-correcting-curropt-file-lines/m-p/3054140#M137221</guid>
      <dc:creator>Declan Heerey</dc:creator>
      <dc:date>2003-08-22T10:49:56Z</dc:date>
    </item>
    <item>
      <title>Re: Finding and correcting curropt file lines</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/finding-and-correcting-curropt-file-lines/m-p/3054141#M137222</link>
      <description>Declan&lt;BR /&gt;&lt;BR /&gt;Massimo has pointed out my missing&lt;BR /&gt;double qoutes in the printf's&lt;BR /&gt;&lt;BR /&gt;and &lt;BR /&gt;&lt;BR /&gt;you might already satisfied with Charles's&lt;BR /&gt;perl script.&lt;BR /&gt;&lt;BR /&gt;but it still looks like there was a syntax&lt;BR /&gt;issue with your script before that.  If your&lt;BR /&gt;still interested in finding out what it was,&lt;BR /&gt;if you'd post your verison, i'm sure we can&lt;BR /&gt;figure out where the problem is.</description>
      <pubDate>Fri, 22 Aug 2003 14:05:39 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/finding-and-correcting-curropt-file-lines/m-p/3054141#M137222</guid>
      <dc:creator>curt larson_1</dc:creator>
      <dc:date>2003-08-22T14:05:39Z</dc:date>
    </item>
  </channel>
</rss>

