Sponsored Content
Full Discussion: Vertical total and listing
Top Forums Shell Programming and Scripting Vertical total and listing Post 302539355 by vakharia Mahesh on Sunday 17th of July 2011 12:23:15 AM
Old 07-17-2011
vertical total

with due apology ,matrixmadhan, for the inconvenience here it is in code tag .
Code:
My code is:
#!/bin/sh
tput clear
tput cup 8 5 
echo -n 'Enter the Minimum Amt :'
read c

awk -F: '{
idx = $2 SUBSEP $4 
arr[idx, ++arrCnt[idx]] = $0
}
END {
for ( i in arrCnt)
if ( arrCnt[i] > 1 )
for ( c=1; c<=arrCnt[i]; c++)
print arr[i,c],TDA[nam]
}' n2 | sort -t: +3 -4d> n3 

awk -F: '{
vou[nam]=$1
dob[nam]=$2
amt[nam]=$3
nam=$4
typ[nam]=$5
TDA[nam]+=$3
}
END {
for ( nam in TDA )
if ( TDA[nam] >= '$c' )
{
printf"%8d:%30s \n",TDA[nam],nam
}}' n3 | sort -t: -n +1 -2d > n4 

#awk -F"[ :]" ' NR==FNR { a[$4]=$0;next} a[$4] {print $0}' n4 n3 > n5

The filed seperator in the original data file is : , Anyway if , say the data required is for Amount more than 3000000 the result expected is as below :

CHA DOB AMOUNT NAME TYPE
37836452 1/13/1961 125000 ASHUTOSH 65
37836505 1/13/1961 500000 ASHUTOSH 49
37836455 1/13/1961 100000 ASHUTOSH 65
37836488 1/13/1961 250000 ASHUTOSH 75
37836473 1/13/1961 125000 ASHUTOSH 49
37836478 1/13/1961 250000 ASHUTOSH 49
37836519 1/13/1961 150000 ASHUTOSH 49
37836437 1/13/1961 500000 ASHUTOSH 49
37836461 1/13/1961 125000 ASHUTOSH 65
37836477 1/13/1961 250000 ASHUTOSH 65
37836486 1/13/1961 250000 ASHUTOSH 65
37836513 1/13/1961 500000 ASHUTOSH 65
37836431 1/13/1961 125000 ASHUTOSH 65 3250000

It should give full details of data.
 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Recursive directory listing without listing files

Does any one know how to get a recursive directory listing in long format (showing owner, group, permission etc) without listing the files contained in the directories. The following command also shows the files but I only want to see the directories. ls -lrtR * (4 Replies)
Discussion started by: psingh
4 Replies

2. HP-UX

Easy one : command listing total memory

Hi, I have been searching for a command that lists the total amount of memory in the HP-UX doc but haven't found it yet. vmstat is not exactly what i want. Does the command exists on HP UX? :confused: :confused: :confused: :confused: :confused: (4 Replies)
Discussion started by: beginer
4 Replies

3. UNIX for Dummies Questions & Answers

grep running total/ final total across multiple files

Ok, another fun hiccup in my UNIX learning curve. I am trying to count the number of occurrences of an IP address across multiple files named example.hits. I can extract the number of occurrences from the files individually but when you use grep -c with multiple files you get the output similar to... (5 Replies)
Discussion started by: MrAd
5 Replies

4. Shell Programming and Scripting

Calculate total space, total used space and total free space in filesystem names matching keyword

Good afternoon! Im new at scripting and Im trying to write a script to calculate total space, total used space and total free space in filesystem names matching a keyword (in this one we will use keyword virginia). Please dont be mean or harsh, like I said Im new and trying my best. Scripting... (4 Replies)
Discussion started by: bigben1220
4 Replies

5. UNIX for Dummies Questions & Answers

vertical tabs

I am trying to get this to display vertically like in a table but it keeps jumping to a new line dev=$(df -h | grep ^/dev | cut -d " " -f1) dev1=$(df -h | grep ^/dev | cut -f 2 -d "%") dev2=$(df -h | grep ^/dev | cut -f 14-16 -d " ") dev3=$(df -h | grep ^/dev | cut -f 18-20 -d " ")... (1 Reply)
Discussion started by: gjanisse
1 Replies

6. UNIX for Dummies Questions & Answers

Horizontal to vertical

Hi, Silly question, if I have an excel file that looks something like this: ................. Subject 1 Subject 2 Subject 3 Subject 4 Fever..............13...........9.............23..........14 Headache.........2............12...........18..........23... (3 Replies)
Discussion started by: Xterra
3 Replies

7. UNIX for Dummies Questions & Answers

vertical to horizontal

dear all, i'm new to unix and i try to figure out the best case for making list of vertical text to become horizontal and skip the line 1 and 2. example text : Data DATE XXXXX MAX 47 53 49 51 48 48 7 46 51 8 25 (6 Replies)
Discussion started by: andrisetia
6 Replies

8. UNIX for Dummies Questions & Answers

[Solved] How to remove listing of current user cmd from ps -ef listing?

Hi All, Could you please help to resolve my following issues: Problem Description: Suppose my user name is "MI90". i.e. $USER = MI90 when i run below command, i get all the processes running on the system containing name MQ. ps -ef | grep MQ But sometimes it lists... (8 Replies)
Discussion started by: KDMishra
8 Replies

9. Shell Programming and Scripting

How do i do the vertical to horizontal??

51009 8746 8912 17986 20315 24998 5368 38934 7805 8566 (4 Replies)
Discussion started by: nikhil jain
4 Replies
All times are GMT -4. The time now is 06:17 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy