<?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 Script Problem in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-script-problem/m-p/3553377#M840522</link>
    <description>Rodney, yes, I usualy do not use printf for this, but in this phase of plugging perl to take over awk, I think I should not push the limits. Pushing the limits, would be using $,, $", and "@{[join]}" just for obfuscational reasons &lt;GRIN&gt;&lt;BR /&gt;&lt;BR /&gt;I also think that with so many fields, csv is to be prefered over '|' separators&lt;BR /&gt;&lt;BR /&gt;Enjoy, Have FUN! H.Merijn&lt;/GRIN&gt;</description>
    <pubDate>Fri, 27 May 2005 14:18:59 GMT</pubDate>
    <dc:creator>H.Merijn Brand (procura</dc:creator>
    <dc:date>2005-05-27T14:18:59Z</dc:date>
    <item>
      <title>AWK Script Problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-script-problem/m-p/3553361#M840506</link>
      <description>I am trying to code a awk script (I'm a newbie) that will parse a file and spit the exceptions to a file; I can get it to display to the screen but not ONLY the exceptions listed in the if statement.. on a second note, if I have lots of values to compare in a if statement, is there a was to code a CASE statement in awk?  Any help would be greatly appreciated and points will be awarded for all help :)   below is my code:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;cat /pei/peifas/ws/wsdata.dat |&lt;BR /&gt;awk 'BEGIN { FS=" "; }&lt;BR /&gt;&lt;BR /&gt;value1 = substr($0, 1, 14)&lt;BR /&gt;gl_acct = 1234&lt;BR /&gt;#acct = substr($0, 4, 8)&lt;BR /&gt;damt = substr($0, 93, 13)&lt;BR /&gt;camt = substr($0, 105, 13)&lt;BR /&gt;desc = "W&amp;amp;S BATCH-" b_month""b_day""b_year&lt;BR /&gt;transamt = damt-camt&lt;BR /&gt;{&lt;BR /&gt;if (value1 = "4111151000000")&lt;BR /&gt;            {      fund=411&lt;BR /&gt;                   acct=2071130&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;printf("||%s|%s||||%s||%s|%s|N|%s/%s/%s|WSIMPORT|WS%s%s%s|||\n", fund, acct, gl_&lt;BR /&gt;acct, desc, transamt, b_month, b_day, b_fullyear, b_month, b_day, b_year)&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;}'&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Darren</description>
      <pubDate>Fri, 27 May 2005 10:11:41 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-script-problem/m-p/3553361#M840506</guid>
      <dc:creator>Darren Etheridge_2</dc:creator>
      <dc:date>2005-05-27T10:11:41Z</dc:date>
    </item>
    <item>
      <title>Re: AWK Script Problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-script-problem/m-p/3553362#M840507</link>
      <description>Try changing your if statement to-&lt;BR /&gt; &lt;BR /&gt;if (value1 == "411115100000")&lt;BR /&gt; &lt;BR /&gt;Rather then using a case statement for multiple tests, you can use the the array syntax-&lt;BR /&gt;a["411115100000"]="411,2071130"&lt;BR /&gt;a["411222200000"]="511,3082240"&lt;BR /&gt;...&lt;BR /&gt;split(a[value1],b,",")&lt;BR /&gt;fund=b[1]&lt;BR /&gt;acct=b[2]&lt;BR /&gt;...&lt;BR /&gt; &lt;BR /&gt;HTH&lt;BR /&gt; &lt;BR /&gt;-- Rod Hills&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 27 May 2005 10:24:29 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-script-problem/m-p/3553362#M840507</guid>
      <dc:creator>Rodney Hills</dc:creator>
      <dc:date>2005-05-27T10:24:29Z</dc:date>
    </item>
    <item>
      <title>Re: AWK Script Problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-script-problem/m-p/3553363#M840508</link>
      <description>How would I kick the true values of the if statement to a file?</description>
      <pubDate>Fri, 27 May 2005 10:29:07 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-script-problem/m-p/3553363#M840508</guid>
      <dc:creator>Darren Etheridge_2</dc:creator>
      <dc:date>2005-05-27T10:29:07Z</dc:date>
    </item>
    <item>
      <title>Re: AWK Script Problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-script-problem/m-p/3553364#M840509</link>
      <description>BTW, attached is my data file</description>
      <pubDate>Fri, 27 May 2005 10:31:09 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-script-problem/m-p/3553364#M840509</guid>
      <dc:creator>Darren Etheridge_2</dc:creator>
      <dc:date>2005-05-27T10:31:09Z</dc:date>
    </item>
    <item>
      <title>Re: AWK Script Problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-script-problem/m-p/3553365#M840510</link>
      <description>You need perl. First, you know awk, so, the way to learn perl from awk is to use a2p (awk to perl translator)&lt;BR /&gt;&lt;BR /&gt;Simplified output from a2p&lt;BR /&gt;&lt;BR /&gt;--8&amp;lt;---&lt;BR /&gt;#!/usr/bin/perl&lt;BR /&gt;&lt;BR /&gt;$[ = 1;                 # set array base to 1&lt;BR /&gt;&lt;BR /&gt;$FS = ' ';&lt;BR /&gt;&lt;BR /&gt;while (&amp;lt;&amp;gt;) {&lt;BR /&gt;    chomp;      # strip record separator&lt;BR /&gt;    print $_ if $value1 = substr($_, 1, 14);&lt;BR /&gt;    print $_ if $gl_acct = 1234;&lt;BR /&gt;    #acct = substr($0, 4, 8)&lt;BR /&gt;    print $_ if $damt = substr($_, 93, 13);&lt;BR /&gt;    print $_ if $camt = substr($_, 105, 13);&lt;BR /&gt;    print $_ if $desc = 'W&amp;amp;S BATCH-' . $b_month . '' . $b_day . '' . $b_year;&lt;BR /&gt;    print $_ if $transamt = $damt - $camt;&lt;BR /&gt;&lt;BR /&gt;    if ($value1 = '4111151000000') {&lt;BR /&gt;        $fund = 411;&lt;BR /&gt;        $acct = 2071130;&lt;BR /&gt;&lt;BR /&gt;        printf "||%s|%s||||%s||%s|%s|N|%s/%s/%s|WSIMPORT|WS%s%s%s|||\n",&lt;BR /&gt;&lt;BR /&gt;          $fund, $acct, $gl_acct, $desc, $transamt, $b_month, $b_day,&lt;BR /&gt;&lt;BR /&gt;          $b_fullyear, $b_month, $b_day, $b_year;&lt;BR /&gt;    }&lt;BR /&gt;}&lt;BR /&gt;--&amp;gt;8---&lt;BR /&gt;&lt;BR /&gt;I know perl much better than awk, and looking at that code, it's probably not what you want&lt;BR /&gt;&lt;BR /&gt;I also don't see b_month, b_day, b_year, and b_fullyear being defined anywhere&lt;BR /&gt;&lt;BR /&gt;In the if statement, you are using = instead of ==, causing an asignment instead of a comparison&lt;BR /&gt;&lt;BR /&gt;--8&amp;lt;---&lt;BR /&gt;#!/usr/bin/perl&lt;BR /&gt;&lt;BR /&gt;while (&amp;lt;&amp;gt;) {&lt;BR /&gt; chomp;&lt;BR /&gt;&lt;BR /&gt; my ($b_day, $b_month, b_year) = (localtime)[3,4,5];&lt;BR /&gt; my $b_fullyear = $b_year + 1900;&lt;BR /&gt;&lt;BR /&gt; my $gl_acct = 1234;&lt;BR /&gt; my ($value1, $damt, $camt) = unpack "A14 x79 A13 A13", $_;&lt;BR /&gt; my $transamt = $damt - $camt;&lt;BR /&gt; my $desc = sprintf "W&amp;amp;S BATCH-%4d%02d%02d", $b_fullyear, $b_month + 1, $b_day;&lt;BR /&gt;&lt;BR /&gt; $value1 eq "4111151000000" or next;&lt;BR /&gt;&lt;BR /&gt; my $fund = 411;&lt;BR /&gt; my $acct = 2071130;&lt;BR /&gt;&lt;BR /&gt; printf "||%s|%s||||%s||%s|%s|N|%s/%s/%s|WSIMPORT|WS%s%s%s|||\n",&lt;BR /&gt;  $fund, $acct, $gl_acct, $desc, $transamt, $b_month, $b_day, $b_fullyear, $b_month, $b_day, $b_year;&lt;BR /&gt;  }&lt;BR /&gt;--&amp;gt;8---&lt;BR /&gt;&lt;BR /&gt;Do my comments make any sense?&lt;BR /&gt;&lt;BR /&gt;Enjoy, Have FUN! H.Merijn</description>
      <pubDate>Fri, 27 May 2005 10:32:20 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-script-problem/m-p/3553365#M840510</guid>
      <dc:creator>H.Merijn Brand (procura</dc:creator>
      <dc:date>2005-05-27T10:32:20Z</dc:date>
    </item>
    <item>
      <title>Re: AWK Script Problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-script-problem/m-p/3553366#M840511</link>
      <description>A typical way to select certain data and print to a file would be-&lt;BR /&gt; &lt;BR /&gt;awk 'if (substr($0,0,4) == "abcd") { print $0 }' &lt;INPUTFILE&gt;outputfile&lt;BR /&gt; &lt;BR /&gt;By redirecting STDOUT to a file, then the lines will be printed to a file...&lt;BR /&gt; &lt;BR /&gt;If you want to get more complicated, like several output files, then you can add "&amp;gt; file" to the print statement.&lt;BR /&gt; &lt;BR /&gt;HTH&lt;BR /&gt; &lt;BR /&gt;-- Rod Hills&lt;/INPUTFILE&gt;</description>
      <pubDate>Fri, 27 May 2005 10:34:47 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-script-problem/m-p/3553366#M840511</guid>
      <dc:creator>Rodney Hills</dc:creator>
      <dc:date>2005-05-27T10:34:47Z</dc:date>
    </item>
    <item>
      <title>Re: AWK Script Problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-script-problem/m-p/3553367#M840512</link>
      <description>Just to make sure I got the numbers right, I took the file from your other post and tested&lt;BR /&gt;&lt;BR /&gt;--8&amp;lt;--- 246551.pl&lt;BR /&gt;#!/usr/bin/perl&lt;BR /&gt;&lt;BR /&gt;use strict;&lt;BR /&gt;use warnings;&lt;BR /&gt;&lt;BR /&gt;while (&amp;lt;&amp;gt;) {&lt;BR /&gt;    my ($b_day, $b_month, $b_year) = (localtime)[3,4,5];&lt;BR /&gt;    my $b_fullyear = $b_year + 1900;&lt;BR /&gt;&lt;BR /&gt;    my $gl_acct = 1234;&lt;BR /&gt;    my ($value1, $damt, $camt) = unpack "A14 x79 A13 A11", $_;&lt;BR /&gt;    #print;&lt;BR /&gt;    #print "$value1|$damt|$camt|\n";&lt;BR /&gt;    my $transamt = $damt - $camt;&lt;BR /&gt;    my $desc = sprintf "W&amp;amp;S BATCH-%4d%02d%02d", $b_fullyear, $b_month + 1, $b_day;&lt;BR /&gt;&lt;BR /&gt;    $value1 eq "4111151000000" or next;&lt;BR /&gt;&lt;BR /&gt;    my $fund = 411;&lt;BR /&gt;    my $acct = 2071130;&lt;BR /&gt;&lt;BR /&gt;    printf "||%s|%s||||%s||%s|%s|N|%s/%s/%s|WSIMPORT|WS%s%s%s|||\n",&lt;BR /&gt; $fund, $acct, $gl_acct, $desc, $transamt,&lt;BR /&gt; $b_month, $b_day, $b_fullyear, $b_month, $b_day, $b_year;&lt;BR /&gt;    }&lt;BR /&gt;--&amp;gt;8---&lt;BR /&gt;&lt;BR /&gt;lt09:/tmp 117 &amp;gt; perl 246551.pl 246551.dat&lt;BR /&gt;||411|2071130||||1234||W&amp;amp;S BATCH-20050527|-16.48|N|4/27/2005|WSIMPORT|WS427105|||&lt;BR /&gt;lt09:/tmp 118 &amp;gt;&lt;BR /&gt;&lt;BR /&gt;Enjoy, Have FUN! H.Merijn</description>
      <pubDate>Fri, 27 May 2005 10:43:44 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-script-problem/m-p/3553367#M840512</guid>
      <dc:creator>H.Merijn Brand (procura</dc:creator>
      <dc:date>2005-05-27T10:43:44Z</dc:date>
    </item>
    <item>
      <title>Re: AWK Script Problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-script-problem/m-p/3553368#M840513</link>
      <description>ok the problem seems to be simple:&lt;BR /&gt;&lt;BR /&gt;for any statement which is not covered by brackets, awk prints the entire record. so to fix your problem&lt;BR /&gt;&lt;BR /&gt;start '{' after BEGIN block.&lt;BR /&gt;&lt;BR /&gt;eg:&lt;BR /&gt;&lt;BR /&gt;awk 'BEGIN { FS=" "; "&lt;BR /&gt;{&lt;BR /&gt;value1 = substr &lt;BR /&gt;...&lt;BR /&gt;&lt;BR /&gt;}'&lt;BR /&gt;&lt;BR /&gt;also the if condition value being used is one character short in length in the dat file you have given. check that too.&lt;BR /&gt;&lt;BR /&gt;as far as i know there is no switch case functionality in awk.&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Gopi</description>
      <pubDate>Fri, 27 May 2005 10:44:24 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-script-problem/m-p/3553368#M840513</guid>
      <dc:creator>Gopi Sekar</dc:creator>
      <dc:date>2005-05-27T10:44:24Z</dc:date>
    </item>
    <item>
      <title>Re: AWK Script Problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-script-problem/m-p/3553369#M840514</link>
      <description>Darren,&lt;BR /&gt;&lt;BR /&gt;If you are only interested in "4111151000000" at the beginning of your record you should code a grep and pipe into awk :&lt;BR /&gt;&lt;BR /&gt;grep ^"4111151000000" /pei/peifas/ws/wsdata.dat | awk '{&lt;BR /&gt;...&lt;BR /&gt;}'&lt;BR /&gt;also the test will be &lt;BR /&gt;if(value1=="...")&lt;BR /&gt;&lt;BR /&gt;Regards&lt;BR /&gt;Jean-Luc</description>
      <pubDate>Fri, 27 May 2005 10:56:29 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-script-problem/m-p/3553369#M840514</guid>
      <dc:creator>Jean-Luc Oudart</dc:creator>
      <dc:date>2005-05-27T10:56:29Z</dc:date>
    </item>
    <item>
      <title>Re: AWK Script Problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-script-problem/m-p/3553370#M840515</link>
      <description>[ 0 points for this nitpicking/debate reply ]&lt;BR /&gt;&lt;BR /&gt;I respectfully disagree with Jean-Luc's suggestion to filter through grep first.&lt;BR /&gt;&lt;BR /&gt;AWK is good at, and happy to, look for the match itself? Why shove the data through grep, into a pipe, into awk?&lt;BR /&gt;&lt;BR /&gt;The same applies to Darren's suggested use of 'cat' to read the file and feed it to awk.&lt;BR /&gt;&lt;BR /&gt;Awk is perfectly happy to read the file itself! Furthermore, awk (or perl) will have the actual filename available which may be useful for more elaborte scripts with error handlers.&lt;BR /&gt;&lt;BR /&gt;And a field seperator of " " is default.&lt;BR /&gt;So the basic awk syntax for this problem is simply:&lt;BR /&gt;&lt;BR /&gt;awk '/^4111151000000/ { fund=... print...}' pei/peifas/ws/wsdata.dat &lt;BR /&gt;&lt;BR /&gt;fwiw,&lt;BR /&gt;Hein.&lt;BR /&gt;</description>
      <pubDate>Fri, 27 May 2005 11:31:28 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-script-problem/m-p/3553370#M840515</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2005-05-27T11:31:28Z</dc:date>
    </item>
    <item>
      <title>Re: AWK Script Problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-script-problem/m-p/3553371#M840516</link>
      <description>Well this part of my script works perfectly.  Now in my input file I have about 100 different account to compare and change values to match our system.  What is the best way to compare each value instead of an if then else structure.. since I can't use CASE, in addition I want the values that don't meet any of the comparisions (TRUE) to be kicked to a dump file.  BTW, Gopi  your answer was KEY to fix my problem... THANKS TO ALL!!!!&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;cat ws.datx &amp;gt;&amp;gt; wsdata.dat &lt;BR /&gt;echo "Parsing wsdata.dat" &amp;gt;&amp;gt; $LOGFL&lt;BR /&gt;&lt;BR /&gt;cat /pei/peifas/ws/wsdata.dat |&lt;BR /&gt;awk 'BEGIN { FS=" "; x = 0; }&lt;BR /&gt;{&lt;BR /&gt; if ( x == 0 ){&lt;BR /&gt;  b_month = substr($0,1,2)&lt;BR /&gt;  b_day = substr($0,3,2)&lt;BR /&gt;  b_fullyear = substr($0,5,4)&lt;BR /&gt;  b_year = substr($0,7,2)&lt;BR /&gt;  x = 1&lt;BR /&gt;} else {&lt;BR /&gt;&lt;BR /&gt;value1 = substr($0, 1, 14)&lt;BR /&gt;gl_acct = 1234&lt;BR /&gt;#acct = substr($0, 4, 8)&lt;BR /&gt;damt = substr($0, 93, 13)&lt;BR /&gt;camt = substr($0, 105, 13)&lt;BR /&gt;desc = "W&amp;amp;S BATCH-" b_month""b_day""b_year&lt;BR /&gt;transamt = damt-camt&lt;BR /&gt;{&lt;BR /&gt;if (value1 == "41122010110296")&lt;BR /&gt;             {      fund="411"&lt;BR /&gt;                    acct="2071130" &lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;printf("||%s|%s||||%s||%s|%s|N|%s/%s/%s|WSIMPORT|WS%s%s%s|||\n", fund, acct, gl_acct, desc, transamt, b_month, b_day, b_fullyear, b_month, b_day, b_year)&lt;BR /&gt;}} &lt;BR /&gt;}&lt;BR /&gt;}' &amp;gt; ws.out&lt;BR /&gt;</description>
      <pubDate>Fri, 27 May 2005 11:43:25 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-script-problem/m-p/3553371#M840516</guid>
      <dc:creator>Darren Etheridge_2</dc:creator>
      <dc:date>2005-05-27T11:43:25Z</dc:date>
    </item>
    <item>
      <title>Re: AWK Script Problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-script-problem/m-p/3553372#M840517</link>
      <description>[ /me shamelessly keeps plugging perl as *the* solution to these growing problems ]&lt;BR /&gt;&lt;BR /&gt;To continue on what I had&lt;BR /&gt;&lt;BR /&gt;somewhere in the beginning you now will have&lt;BR /&gt;&lt;BR /&gt;my %hash = (&lt;BR /&gt; # value =&amp;gt; [ fund, acct ]&lt;BR /&gt; 4111151000000 =&amp;gt; [ 411, 2071130 ],&lt;BR /&gt; 4213253710000 =&amp;gt; [ 421, 2098812 ],&lt;BR /&gt; :&lt;BR /&gt; :&lt;BR /&gt; );&lt;BR /&gt;&lt;BR /&gt;then where I had the test,&lt;BR /&gt;&lt;BR /&gt;exists $hash{$value1} or next;&lt;BR /&gt;my ($fund, $acct) = @{$hash{$value1}};&lt;BR /&gt;&lt;BR /&gt;printf "||%s|%s||||%s||%s|%s|N|%s/%s/%s|WSIMPORT|WS%s%s%s|||\n",&lt;BR /&gt;$fund, $acct, $gl_acct, $desc, $transamt,&lt;BR /&gt;$b_month, $b_day, $b_fullyear, $b_month, $b_day, $b_year;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;and you don't need no switch/case at all!&lt;BR /&gt;&lt;BR /&gt;Enjoy, Have FUN! H.Merijn</description>
      <pubDate>Fri, 27 May 2005 11:56:02 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-script-problem/m-p/3553372#M840517</guid>
      <dc:creator>H.Merijn Brand (procura</dc:creator>
      <dc:date>2005-05-27T11:56:02Z</dc:date>
    </item>
    <item>
      <title>Re: AWK Script Problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-script-problem/m-p/3553373#M840518</link>
      <description>My first post showed how to do it with "awk" using "associative arrays". It is similar to what Procura demonstrated. If you text processing gets much more complicated, then "perl" would be the more prefered tool.&lt;BR /&gt; &lt;BR /&gt;My 2 cents&lt;BR /&gt; &lt;BR /&gt;-- Rod Hills</description>
      <pubDate>Fri, 27 May 2005 12:25:53 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-script-problem/m-p/3553373#M840518</guid>
      <dc:creator>Rodney Hills</dc:creator>
      <dc:date>2005-05-27T12:25:53Z</dc:date>
    </item>
    <item>
      <title>Re: AWK Script Problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-script-problem/m-p/3553374#M840519</link>
      <description>Procura,&lt;BR /&gt;&lt;BR /&gt;I'm thought you might have changed-&lt;BR /&gt;printf "||%s|%s||||%s||%s|%s|N|%s/%s/%s|WSIMPORT|WS%s%s%s|||\n",&lt;BR /&gt;$fund, $acct, $gl_acct, $desc, $transamt,&lt;BR /&gt;$b_month, $b_day, $b_fullyear, $b_month, $b_day, $b_year; &lt;BR /&gt; &lt;BR /&gt;to use join-&lt;BR /&gt;print join("|","","",$fund, $acct, "","","",$gl_acct,"", $desc, $transamt,"N",join("/",$b_month, $b_day, $b_fullyear), "WS".$b_month.$b_day.$b_year,"","",""),"\n";&lt;BR /&gt; &lt;BR /&gt;Which I think is more readable then a printf... &lt;BR /&gt; &lt;BR /&gt;My 4 cents...&lt;BR /&gt; &lt;BR /&gt;-- Rod Hills</description>
      <pubDate>Fri, 27 May 2005 12:33:36 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-script-problem/m-p/3553374#M840519</guid>
      <dc:creator>Rodney Hills</dc:creator>
      <dc:date>2005-05-27T12:33:36Z</dc:date>
    </item>
    <item>
      <title>Re: AWK Script Problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-script-problem/m-p/3553375#M840520</link>
      <description>Rodney,&lt;BR /&gt;I tried using the array syntax you advised but can't seem to get it to only process the TRUE values of the array... How would I do this?&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;transamt = damt-camt&lt;BR /&gt;&lt;BR /&gt;#if (value1 == "41122010110296")&lt;BR /&gt;#             {      fund="411"&lt;BR /&gt;#                    acct="2071130"&lt;BR /&gt;{&lt;BR /&gt;a["41122010110296"]="411,2071130"&lt;BR /&gt;&lt;BR /&gt;split(a[value1],b,",")&lt;BR /&gt;&lt;BR /&gt;fund=b[1]&lt;BR /&gt;acct=b[2]&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;printf("||%s|%s||||%s||%s|%s|N|%s/%s/%s|WSIMPORT|WS%s%s%s|||\n", fund, acct, gl_&lt;BR /&gt;acct, desc, transamt, b_month, b_day, b_fullyear, b_month, b_day, b_year)&lt;BR /&gt;&lt;BR /&gt;}&lt;BR /&gt;}'&lt;BR /&gt;</description>
      <pubDate>Fri, 27 May 2005 13:36:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-script-problem/m-p/3553375#M840520</guid>
      <dc:creator>Darren Etheridge_2</dc:creator>
      <dc:date>2005-05-27T13:36:35Z</dc:date>
    </item>
    <item>
      <title>Re: AWK Script Problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-script-problem/m-p/3553376#M840521</link>
      <description>You will need one if statement.&lt;BR /&gt; &lt;BR /&gt;BEGIN{&lt;BR /&gt;a["411115100000"]="411,2071130"&lt;BR /&gt;a["411222200000"]="511,3082240"&lt;BR /&gt;}&lt;BR /&gt;{&lt;BR /&gt;value1=substr($0,1,14)&lt;BR /&gt;...&lt;BR /&gt;if (a[value1]) {&lt;BR /&gt;split(a[value1],b,",")&lt;BR /&gt;fund=b[1]&lt;BR /&gt;acct=b[2]&lt;BR /&gt;print value1,fund,acct&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt; &lt;BR /&gt;If a[value1] does not have a value, which means you have not set a predefined mapping in the BEGIN block, then the if block will not print the record.&lt;BR /&gt; &lt;BR /&gt;HTH&lt;BR /&gt; &lt;BR /&gt;-- Rod Hills&lt;BR /&gt; &lt;BR /&gt;</description>
      <pubDate>Fri, 27 May 2005 13:47:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-script-problem/m-p/3553376#M840521</guid>
      <dc:creator>Rodney Hills</dc:creator>
      <dc:date>2005-05-27T13:47:35Z</dc:date>
    </item>
    <item>
      <title>Re: AWK Script Problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-script-problem/m-p/3553377#M840522</link>
      <description>Rodney, yes, I usualy do not use printf for this, but in this phase of plugging perl to take over awk, I think I should not push the limits. Pushing the limits, would be using $,, $", and "@{[join]}" just for obfuscational reasons &lt;GRIN&gt;&lt;BR /&gt;&lt;BR /&gt;I also think that with so many fields, csv is to be prefered over '|' separators&lt;BR /&gt;&lt;BR /&gt;Enjoy, Have FUN! H.Merijn&lt;/GRIN&gt;</description>
      <pubDate>Fri, 27 May 2005 14:18:59 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-script-problem/m-p/3553377#M840522</guid>
      <dc:creator>H.Merijn Brand (procura</dc:creator>
      <dc:date>2005-05-27T14:18:59Z</dc:date>
    </item>
  </channel>
</rss>

