- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: AWK Script Problem
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
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
тАО05-27-2005 04:43 AM
тАО05-27-2005 04:43 AM
Re: AWK Script Problem
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
{
if (value1 == "41122010110296")
{ fund="411"
acct="2071130"
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-27-2005 04:56 AM
тАО05-27-2005 04:56 AM
Re: AWK Script Problem
To continue on what I had
somewhere in the beginning you now will have
my %hash = (
# value => [ fund, acct ]
4111151000000 => [ 411, 2071130 ],
4213253710000 => [ 421, 2098812 ],
:
:
);
then where I had the test,
exists $hash{$value1} or next;
my ($fund, $acct) = @{$hash{$value1}};
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;
and you don't need no switch/case at all!
Enjoy, Have FUN! H.Merijn
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-27-2005 05:25 AM
тАО05-27-2005 05:25 AM
Re: AWK Script Problem
My 2 cents
-- Rod Hills
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-27-2005 05:33 AM
тАО05-27-2005 05:33 AM
Re: AWK Script Problem
I'm thought you might have changed-
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;
to use join-
print join("|","","",$fund, $acct, "","","",$gl_acct,"", $desc, $transamt,"N",join("/",$b_month, $b_day, $b_fullyear), "WS".$b_month.$b_day.$b_year,"","",""),"\n";
Which I think is more readable then a printf...
My 4 cents...
-- Rod Hills
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-27-2005 06:36 AM
тАО05-27-2005 06:36 AM
Re: AWK Script Problem
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?
transamt = damt-camt
#if (value1 == "41122010110296")
# { fund="411"
# acct="2071130"
{
a["41122010110296"]="411,2071130"
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)
}
}'
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-27-2005 06:47 AM
тАО05-27-2005 06:47 AM
Re: AWK Script Problem
BEGIN{
a["411115100000"]="411,2071130"
a["411222200000"]="511,3082240"
}
{
value1=substr($0,1,14)
...
if (a[value1]) {
split(a[value1],b,",")
fund=b[1]
acct=b[2]
print value1,fund,acct
}
}
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.
HTH
-- Rod Hills
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-27-2005 07:18 AM
тАО05-27-2005 07:18 AM
Re: AWK Script Problem
I also think that with so many fields, csv is to be prefered over '|' separators
Enjoy, Have FUN! H.Merijn
- « Previous
-
- 1
- 2
- Next »