The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Problem to send rtf inline body srik_ux UNIX for Dummies Questions & Answers 7 05-30-2008 12:30 PM
printing all array values using dbx 7.2.1 JamesGoh High Level Programming 1 12-18-2007 04:07 PM
Inline Parameters-Urgent indira Shell Programming and Scripting 2 05-02-2007 05:02 PM
sed / awk - inplace or inline edit hemangjani Shell Programming and Scripting 6 02-22-2007 06:40 AM
Will exe file size decrease while using inline function vijaysabari High Level Programming 1 08-31-2005 11:45 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 05-12-2008
vakharia Mahesh vakharia Mahesh is offline
Registered User
  
 

Join Date: Feb 2007
Posts: 51
Question Array Printing Inline

Dear friends ,
The output file of below script
Pls#!/bin/sh

awk '{
bo = substr($0,13,3)
slm = substr($0,150,8)
slo = substr($0,175,7)
inc = substr($0,97,10)/100
busi = substr($0,83,10)
mth = substr($0,39,2)
yer = substr($0,35,4)
printf"%3s:%8s:%7d:%10.2f:%10d:%.2d:%4d \n",bo,slm,slo,inc,busi,mth,yer
}' infile | sort -t: +6 -7 +5 -6 +2 -3n +1 -2d > tmpout

awk -F":" '{
br = $1
slm = $2
slo = $3
inc = $4
busi = $5
mth = $6
yer = $7
CTR[bo,slm,yer,mth] +=1
TINC[bo,slm,yer,mth] +=inc
BUS[bo,slm,yer,mth] +=busi
SLM [bo,slm,yer,mth] =slm
SLO1[bo,slm,yer,mth] =slo
MTH[bo,slm,yer,mth] =mth
YER[bo,slm,yer,mth] =yer
}
END {
for ( c in CTR)
printf" %.2d: %4d: %8s: %7d: %4d: %13.2f: %13d\n",MTH[c],YER[c],SLM[c],SLO1[c],CTR[c],TINC[c],BUS[c] | "sort -t: +3 -4n +2 -3d +1 -2 +0 -1"
}' tmpout > list.prt

------------------------------------------------------------------------
MTH YEAR SLM SLO CTR INCOME BUSINESS
================================================================
05: 2006: 0068683: 1234: 1: 940.00: 100000
06: 2006: 0068683: 1234: 2: 10094.00: 200000
07: 2006: 0068683: 1234: 1: 50000.00: 0
09: 2006: 0068683: 1234: 1: 677.00: 50000
11: 2006: 0068683: 1234: 1: 27109.00: 500000
12: 2006: 0068683: 1234: 1: 54800.00: 100000
01: 2007: 0068683: 1234: 5: 57596.00: 1300000
03: 2007: 0068683: 1234: 7: 87438.00: 1700000
05: 2007: 0068683: 1234: 1: 1251.00: 150000
06: 2007: 0068683: 1234: 2: 24844.00: 1000000
07: 2007: 0068683: 1234: 1: 10330.00: 200000
09: 2007: 0068683: 1234: 1: 1271.00: 150000
10: 2007: 0068683: 1234: 2: 13456.00: 1000000
02: 2008: 0068683: 1234: 2: 21603.00: 500000
03: 2008: 0068683: 1234: 12: 277414.00: 1900000
04: 2006: 0097883: 1234: 2: 50599.00: 65000
05: 2006: 0097883: 1234: 2: 21939.00: 125000
07: 2006: 0097883: 1234: 16: 200450.00: 35000
11: 2006: 0097883: 1234: 1: 2258.00: 50000
12: 2006: 0097883: 1234: 2: 32000.00: 0
03: 2007: 0097883: 1234: 29: 230000.00: 1615000
04: 2007: 0097883: 1234: 6: 52964.00: 550000
06: 2007: 0097883: 1234: 1: 2940.00: 50000
07: 2007: 0097883: 1234: 1: 10000.00: 0
08: 2007: 0097883: 2468: 6: 52384.00: 550000
-----------------------------------------------------------------------
The out put requires is
SLO ( Salesofficer) 1234
==========================================================

SLM (CY) 03/2006 04/2006 05/2006 06/2006 07/2006 08/2006 09/2006
---------------------------------------------------------------------------
0068683 000 000 100000 200000 000 000 50000
000 000 940.00 10094.00 50000 000 677.00
---------------------------------------------------------------------------
0097883 000 65000 125000 000 35000 000 000
000 50599 219339.00 000 200450.00 000 000
--------------------------------------------------------------------------
and likewise . on first line the month and year , on the second line SLM-ID
and continue with the business he has done and on the third line the incom
he has earned .where there is nothing will print 000( zero zero zero) .
Can you suggest what change I have to make in my script ??

The same is possible in perl ??


Thanks in advance .

Last edited by vakharia Mahesh; 05-20-2008 at 08:31 AM..
  #2 (permalink)  
Old 05-20-2008
era era is offline Forum Advisor  
Herder of Useless Cats (On Sabbatical)
  
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,652
The a2p script which ships with Perl can convert many awk scripts to Perl, although the result is not always pretty. The answer to "possible in Perl" would be "yes" in any event; anything awk can do, Perl can do too. (Computer science has a formal proof but I expect you don't want it.)
  #3 (permalink)  
Old 05-21-2008
vakharia Mahesh vakharia Mahesh is offline
Registered User
  
 

Join Date: Feb 2007
Posts: 51
Unhappy array printing

Thanks Era for your reply , that did not give me the desired result
, have also tried with pr -a 3 ( i.e. printing accross ) you must be
well aware but that too failed. So I have great hope that there are
Gurus at this site will surely have some solution , I was waiting for
that .Anyway thanks lot . I think the matter is closed now.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 07:50 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0