<?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: Awk / sed script help. in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-sed-script-help/m-p/4460552#M679989</link>
    <description>James here is some sample output. I had to XXXXX a bunch of stuff out but the important stuff is there. That is why I didnt post it originally.&lt;BR /&gt;&lt;BR /&gt;OldSchool, thanks I will give this a try.&lt;BR /&gt;&lt;BR /&gt;many thanks fellas.&lt;BR /&gt;&lt;BR /&gt;DCJ</description>
    <pubDate>Wed, 15 Jul 2009 18:09:10 GMT</pubDate>
    <dc:creator>D. Jackson_1</dc:creator>
    <dc:date>2009-07-15T18:09:10Z</dc:date>
    <item>
      <title>Awk / sed script help.</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-sed-script-help/m-p/4460549#M679986</link>
      <description>How do all...&lt;BR /&gt;I am needing some assistance with a shell script.&lt;BR /&gt;&lt;BR /&gt;I have a master file that is pipe "|" delimited.&lt;BR /&gt;My goal is to search through the file looking specifically for a few fields and if they meet a condition I have to change one of the fields and save the file.&lt;BR /&gt;&lt;BR /&gt;Here is what I am looking for:&lt;BR /&gt;&lt;BR /&gt;If COL 165 is = to COMPANY PAID and COL 63 does not = AIRFARE - DIRECT BILLED then within that same line replace COL 165 COMPANY PAID with JPMC CORPORATE CARD and save file.&lt;BR /&gt;Same conditions for every line with specifics of above.&lt;BR /&gt;I would rather not use perl unless it is a last resort.&lt;BR /&gt;&lt;BR /&gt;Many thanks (points will be awarded)&lt;BR /&gt;&lt;BR /&gt;DCJ</description>
      <pubDate>Wed, 15 Jul 2009 17:20:14 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-sed-script-help/m-p/4460549#M679986</guid>
      <dc:creator>D. Jackson_1</dc:creator>
      <dc:date>2009-07-15T17:20:14Z</dc:date>
    </item>
    <item>
      <title>Re: Awk / sed script help.</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-sed-script-help/m-p/4460550#M679987</link>
      <description>Hi:&lt;BR /&gt;&lt;BR /&gt;Posting an actual file (as an attachment) is far more helpful than a word description of columns and column contents.&lt;BR /&gt;&lt;BR /&gt;If their are less than 199 fields in the file, 'awk' may suffice.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Wed, 15 Jul 2009 17:49:46 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-sed-script-help/m-p/4460550#M679987</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2009-07-15T17:49:46Z</dc:date>
    </item>
    <item>
      <title>Re: Awk / sed script help.</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-sed-script-help/m-p/4460551#M679988</link>
      <description>&lt;!--!*#--&gt;If you meant "fields" where you said "columns", then this should be a start.  Be aware that if you have a lot of fields ( &amp;gt; 200?) awk may present issues.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;BEGIN {&lt;BR /&gt;FS="|";&lt;BR /&gt;OFS="|";&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;{&lt;BR /&gt;if ($165 == "COMPANY PAID" &amp;amp;&amp;amp; $63 != "AIRFARE - DIRECT BILLED")&lt;BR /&gt; {&lt;BR /&gt; $165 = "COMPANY PAID with JMPC CORPORATE CARD";&lt;BR /&gt; }&lt;BR /&gt;&lt;BR /&gt;print $0;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;END{&lt;BR /&gt;}</description>
      <pubDate>Wed, 15 Jul 2009 18:02:18 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-sed-script-help/m-p/4460551#M679988</guid>
      <dc:creator>OldSchool</dc:creator>
      <dc:date>2009-07-15T18:02:18Z</dc:date>
    </item>
    <item>
      <title>Re: Awk / sed script help.</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-sed-script-help/m-p/4460552#M679989</link>
      <description>James here is some sample output. I had to XXXXX a bunch of stuff out but the important stuff is there. That is why I didnt post it originally.&lt;BR /&gt;&lt;BR /&gt;OldSchool, thanks I will give this a try.&lt;BR /&gt;&lt;BR /&gt;many thanks fellas.&lt;BR /&gt;&lt;BR /&gt;DCJ</description>
      <pubDate>Wed, 15 Jul 2009 18:09:10 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-sed-script-help/m-p/4460552#M679989</guid>
      <dc:creator>D. Jackson_1</dc:creator>
      <dc:date>2009-07-15T18:09:10Z</dc:date>
    </item>
    <item>
      <title>Re: Awk / sed script help.</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-sed-script-help/m-p/4460553#M679990</link>
      <description>hmm.. i tried mine on an AIX box and it reports that you've 256 fields...which may not work w/ HP-UX's version of awk</description>
      <pubDate>Wed, 15 Jul 2009 18:19:10 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-sed-script-help/m-p/4460553#M679990</guid>
      <dc:creator>OldSchool</dc:creator>
      <dc:date>2009-07-15T18:19:10Z</dc:date>
    </item>
    <item>
      <title>Re: Awk / sed script help.</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-sed-script-help/m-p/4460554#M679991</link>
      <description>OldSchool, &lt;BR /&gt;I forgot to even mention I was doing this on (cough cough) Solaris... :)&lt;BR /&gt;&lt;BR /&gt;Your snippet led me down the what looks to be correct path.&lt;BR /&gt;&lt;BR /&gt;Here is what my command looks like to do this:&lt;BR /&gt;&lt;BR /&gt;cat TEST.txt | nawk 'BEGIN { FS="|"; OFS="|"; } { if ($165 == "COMPANY PAID" &amp;amp;&amp;amp; $63 != "AIRFARE - DIRECT BILLED") { $165 = "JMPC CORPORATE CARD"; } print $0; } END{ }' &amp;gt; NEWTEST.txt&lt;BR /&gt;&lt;BR /&gt;Just for my sanity do you all mind trying this to confirm?&lt;BR /&gt;&lt;BR /&gt;Thanks abunch fellas I just needed a little guidance.&lt;BR /&gt;&lt;BR /&gt;Thanks again&lt;BR /&gt;DCJ</description>
      <pubDate>Wed, 15 Jul 2009 18:39:58 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-sed-script-help/m-p/4460554#M679991</guid>
      <dc:creator>D. Jackson_1</dc:creator>
      <dc:date>2009-07-15T18:39:58Z</dc:date>
    </item>
    <item>
      <title>Re: Awk / sed script help.</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-sed-script-help/m-p/4460555#M679992</link>
      <description>&lt;!--!*#--&gt;Hi:&lt;BR /&gt;&lt;BR /&gt;Based on your data, I see more than 199 fields too.  The good old 'awk' is going to choke on that, but Perl never will.&lt;BR /&gt;&lt;BR /&gt;Try this:&lt;BR /&gt;&lt;BR /&gt;# cat ./reformat&lt;BR /&gt;#!/usr/bin/perl&lt;BR /&gt;use strict;&lt;BR /&gt;my @a;&lt;BR /&gt;while (&amp;lt;&amp;gt;) {&lt;BR /&gt;    @a = split /\|/;&lt;BR /&gt;    if ( $a[164] eq 'COMPANY PAID' &amp;amp;&amp;amp; $a[62] ne 'AIRFARE - DIRECT BILLED' ) {&lt;BR /&gt;        print join '|', @a[ 0 .. 163 ],&lt;BR /&gt;            'COMPANY PAID with JMPC CORPORATE CARD', @a[ 165 .. $#a + 1 ];&lt;BR /&gt;    }&lt;BR /&gt;    else {&lt;BR /&gt;        print;&lt;BR /&gt;    }&lt;BR /&gt;}&lt;BR /&gt;1;&lt;BR /&gt;&lt;BR /&gt;...run as:&lt;BR /&gt;&lt;BR /&gt;# ./reformat file&lt;BR /&gt;&lt;BR /&gt;Note that Perl counts zero-relative, so I adjusted the field counts accordingly.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Wed, 15 Jul 2009 18:49:13 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-sed-script-help/m-p/4460555#M679992</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2009-07-15T18:49:13Z</dc:date>
    </item>
    <item>
      <title>Re: Awk / sed script help.</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-sed-script-help/m-p/4460556#M679993</link>
      <description>&lt;!--!*#--&gt;cat TEST.txt | nawk 'BEGIN { FS="|"; OFS="|"; } { if ($165 == "COMPANY PAID" &amp;amp;&amp;amp; $63 != "AIRFARE - DIRECT BILLED") { $165 = "JMPC CORPORATE CARD"; } print $0; } END{ }' &amp;gt; NEWTEST.txt&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;well, it worked on AIX, changed 2 records in the test data provided.&lt;BR /&gt;&lt;BR /&gt;but....&lt;BR /&gt;&lt;BR /&gt;1) skip the "cat', its not needed...&lt;BR /&gt;&lt;BR /&gt;nawk 'BEGIN { FS="|"; OFS="|"; } { if ($165 == "COMPANY PAID" &amp;amp;&amp;amp; $63 != "AIRFARE - DIRECT BILLED") { $165 = "JMPC CORPORATE CARD"; } print $0; } END{ }' TEST.txt &amp;gt; NEWTEST.txt&lt;BR /&gt;&lt;BR /&gt;will let nawk read / process the file itself....and &lt;BR /&gt;&lt;BR /&gt;2) not sure why you'd want one long command line... to me, something like this:&lt;BR /&gt;&lt;BR /&gt;cat cardchange.awk&lt;BR /&gt;BEGIN { &lt;BR /&gt;FS="|"; &lt;BR /&gt;OFS="|"; &lt;BR /&gt;} &lt;BR /&gt;&lt;BR /&gt;{ &lt;BR /&gt;if ($165 == "COMPANY PAID" &amp;amp;&amp;amp; $63 != "AIRFARE - DIRECT BILLED") &lt;BR /&gt; { &lt;BR /&gt; $165 = "JMPC CORPORATE CARD"; &lt;BR /&gt; } &lt;BR /&gt;print $0; &lt;BR /&gt;} &lt;BR /&gt;&lt;BR /&gt;END{ &lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;used with:&lt;BR /&gt;&lt;BR /&gt;nawk -f cardchange.awk TEST.txt &amp;gt; NEWTEST.txt&lt;BR /&gt;&lt;BR /&gt;is just easier to maintain&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 15 Jul 2009 19:06:51 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-sed-script-help/m-p/4460556#M679993</guid>
      <dc:creator>OldSchool</dc:creator>
      <dc:date>2009-07-15T19:06:51Z</dc:date>
    </item>
  </channel>
</rss>

