- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: AWK Revisited Help
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-02-2005 03:14 AM
тАО06-02-2005 03:14 AM
#### Time / Date stamp file & Process
cat ws.datx >> wsdata.dat
echo "Parsing wsdata.dat" >> $LOGFL
cat /pei/peifas/ws/wsdata.dat |
awk 'BEGIN { FS=" "; x = 0; }
{
if ( x == 0 ){
b_month = substr($0,1,2)
b_day = substr($0,3,2)
b_fullyear = substr($0,5,4)
b_year = substr($0,7,2)
x = 1
} else {
value1 = substr($0, 1, 14)
gl_acct = 1234
#acct = substr($0, 4, 8)
damt = substr($0, 93, 13)
camt = substr($0, 105, 13)
desc = "W&S BATCH-" b_month""b_day""b_year
transamt = damt-camt
############# WS Case number & Clerk Equiv ##############
a["4111151000000"] = "411,2071130"
a["11310410110912"] = "411,1041010"
a["11310410110913"] = "411,1041010"
a["11310410110915"] = "411,1041010"
.
.
.
a["43034341010212"] = "411,2074300"
a["43034341010311"] = "411,2074300"
############################################################
if (a[value1]) {
split(a[value1],b,",")
fund=b[1]
acct=b[2]
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)
} }
}' > ws.out
echo "Created ws.out file successfully " >> $LOGFL
(data file attached)
Your help is appreciated@!!!
Darren
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-02-2005 05:32 AM
тАО06-02-2005 05:32 AM
Re: AWK Revisited Help
have you tried the "join" command.
may answer your issues.
man join
Regards
Jean-Luc
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-02-2005 05:34 AM
тАО06-02-2005 05:34 AM
Solutionif (a[value1]) {
split(a[value1],b,",")
fund=b[1]
acct=b[2]
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)
} else {print $0 >"exception.out" }
}' > ws.out
This include a else clause with a print to an exception file...
HTH
-- Rod Hills
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-02-2005 05:47 AM
тАО06-02-2005 05:47 AM
Re: AWK Revisited Help
my first Idea was like Rodneys approach, but I doubt that you ca use a sepeate redirect inside "awk" (but not sure).
What sure will work is to print a line
EXCEPTION: $0
and divide the resultfile with two greps
grep EXCEPTION ws.dat > except.dat
grep -v EXCEPTION ws.dat > ok.dat
Volker
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-02-2005 06:38 AM
тАО06-02-2005 06:38 AM
Re: AWK Revisited Help
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-02-2005 06:39 AM
тАО06-02-2005 06:39 AM
Re: AWK Revisited Help
Try some perl:
#!/usr/bin/perl
#
use POSIX qw(strftime);
$savedate = strftime "%Y%m%d.%H%M%S", gmtime();
$LOGFL="ws.log";
system("cat ws.datx >> wsdata.dat");
open(LOGFILEptr,">>${LOGFL}");
open(WSerrorfile,">ws.errs");
open(WSnewoutputfile,">ws.out");
open(WSinputfile,"<./wsdata.dat");
printf(LOGFILEptr "Parsing accttest.data @ %s.\n",$savedate);
$x = 0;
$a = "";
while (
if ( $x == 0 ) {
$b_month = substr($_,0,2);
$b_day = substr($_,2,2);
$b_fullyear = substr($_,4,4);
$b_year = substr($_,6,2);
$x = 1;
} else {
$value1 = substr($_, 0, 14);
$gl_acct = 1234;
# $acct = substr($_, 3, 8);
$damt = substr($_, 92, 13);
$camt = substr($_, 104, 13);
$desc = "W&S BATCH-" . $b_month . $b_day . $b_year;
$transamt = $damt - $camt;
############# WS Case number & Clerk Equiv ##############
$a{"4111151000000"} = "411,2071130";
$a{"11310410110912"} = "411,1041010";
$a{"11310410110913"} = "411,1041010";
$a{"11310410110915"} = "411,1041010";
$a{"43034341010212"} = "411,2074300";
$a{"43034341010311"} = "411,2074300";
############################################################
if ($a{$value1}) {
@b = split(/,/,$a{$value1});
$fund=@b[0];
$acct=@b[1];
printf(WSnewoutputfile "||%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);
} else {
printf(WSerrorfile $_);
}
}
}
$savedate = strftime "%Y%m%d.%H%M%S", gmtime();
printf(LOGFILEptr "Created ws.out file successfully @ %s.\n",$savedate);
perl and awk syntax are similar, but perl uses 0 as the first element in an array or substring (so I decremented one from the starting positions for substr)
live free or die
harry d brown jr
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-02-2005 07:21 AM
тАО06-02-2005 07:21 AM
Re: AWK Revisited Help
my %a = (
4111151000000 => [ 411, 2071130 ],
11310410110912 => [ 411, 1041010 ],
11310410110913 => [ 411, 1041010 ],
11310410110915 => [ 411, 1041010 ],
43034341010212 => [ 411, 2074300 ],
43034341010311 => [ 411, 2074300 ],
);
############################################################
if (exists $a{$value1}) {
my ($fund, $acct) = @{$a{$value1}};
Enjoy, Have FUN! H.Merijn
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-02-2005 07:33 AM
тАО06-02-2005 07:33 AM
Re: AWK Revisited Help
correct as usual. I was just doing a quick and dirty (slap my hand).
live free or die
harry d brown jr
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-02-2005 08:31 AM
тАО06-02-2005 08:31 AM
Re: AWK Revisited Help
} else {print $0 >"exception.out" }}
Better would be to use perl, like Procura's solution.
HTH
-- Rod Hills
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-02-2005 09:49 AM
тАО06-02-2005 09:49 AM
Re: AWK Revisited Help
That did the trick!!!! Thank you for all of your help.. I am learning PERL but just not proficent enough to code in it yet :) Thank you all for your help... All are assigned points :)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-02-2005 09:50 AM
тАО06-02-2005 09:50 AM