Sponsored Content
Top Forums UNIX for Advanced & Expert Users find and group records in a file Post 302114940 by mike_ap2006 on Thursday 19th of April 2007 02:58:42 PM
Old 04-19-2007
Hi Vgersh,

This command is working perfect in command line.

when i m using this code it gives an error "
awk: sum is not an array"

Can u please help. Sorry to bother you again. Thanks a lot!!

WORKING_DIR="/opt/apps/manu/custcpfr/temp/perl_poc"
OUTPUT_FILENAME="temp.dat"

ctlfile="test.ctl"
AGGR_VALUE=`grep ^AGGREGATE $ctlfile`

AGGREGATE=`echo $AGGR_VALUE | cut -f2 -d "=" | sed -e 's/^ //g'`

echo $AGGREGATE

if [ $AGGREGATE = "YES" ]
then
echo "Right"
fi

if [ $AGGREGATE = "YES" ]
then
`awk -F"|" '{ idx=$2 FS $3 FS $4 FS $5; sum[idx] += $7; first[idx]=$1;sixth[idx]=$6 } END { for (record in sum) printf("%s%s%s%s%s%s%s\n", first[record], FS, record, FS, sixth[idx], FS, sum[record]) }' $WORKING_DIR/$OUTPUT_FILENAME > $WORKING_DIR/$OUTPUT_FILENAME`

fi
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to find Duplicate Records in a text file

Hi all pls help me by providing soln for my problem I'm having a text file which contains duplicate records . Example: abc 1000 3452 2463 2343 2176 7654 3452 8765 5643 3452 abc 1000 3452 2463 2343 2176 7654 3452 8765 5643 3452 tas 3420 3562 ... (1 Reply)
Discussion started by: G.Aavudai
1 Replies

2. Shell Programming and Scripting

find out duplicate records in file?

Dear All, I have one file which looks like : account1:passwd1 account2:passwd2 account3:passwd3 account1:passwd4 account5:passwd5 account6:passwd6 you can see there're two records for account1. and is there any shell command which can find out : account1 is the duplicate record in... (3 Replies)
Discussion started by: tiger2000
3 Replies

3. Shell Programming and Scripting

KSH to group records in a file and compare it with another file

Hi, I've a file like below: DeptFile.csv DeptID EmpID ------- ------ Dep01 Emp01 Dep01 Emp02 Dep01 Emp03 Dep02 Emp04 Dep02 Emp05 I've another file which has EmpFile.csv EmpID Salary ------ ------ (3 Replies)
Discussion started by: Matrix2682
3 Replies

4. Shell Programming and Scripting

how to group records in a file

hi, I have records like this D127@dm.com,127,569,BRAD,25/08/2009 23:59 D127@dm.com,127,569,BRAD,25/08/2009 23:59 D159@dm.com,159,1170,DAVE,25/08/2009 23:59 D159@dm.com,159,1181,HALE,25/08/2009 23:59 D393@dm.com,393,1209,CAPIT,25/08/2009 23:59 D457@dm.com,457,571,NORTT,25/08/2009 23:59... (4 Replies)
Discussion started by: trichyselva
4 Replies

5. Shell Programming and Scripting

Find Duplicate records in first Column in File

Hi, Need to find a duplicate records on the first column, ANU4501710430989 0000000W20389390 ANU4501710430989 0000000W67065483 ANU4501130050520 0000000W80838713 ANU4501210170685 0000000W69246611... (3 Replies)
Discussion started by: Murugesh
3 Replies

6. UNIX for Dummies Questions & Answers

How to find particular records in a file?

Hi all, i have one file contains 20 records 1 2 - - - 20 i want to find 5th records and 8th records and 14th plz tell me which command use? Thanks to advance (4 Replies)
Discussion started by: venkatreddy
4 Replies

7. UNIX for Dummies Questions & Answers

CSV file:Find duplicates, save original and duplicate records in a new file

Hi Unix gurus, Maybe it is too much to ask for but please take a moment and help me out. A very humble request to you gurus. I'm new to Unix and I have started learning Unix. I have this project which is way to advanced for me. File format: CSV file File has four columns with no header... (8 Replies)
Discussion started by: arvindosu
8 Replies

8. UNIX for Dummies Questions & Answers

Find a file in group of jars

Hi, jar -tvf tools.jar | grep LinkInfoImpl Output: 4968 Fri Feb 22 02:34:52 EST 2008 com/sun/tools/doclets/formats/html/LinkInfoImpl.class However, i need the similar output for all jar files under /apps/lib/ directory and its subdirectories. Can you please help format my command to... (3 Replies)
Discussion started by: mohtashims
3 Replies

9. Shell Programming and Scripting

Script to find blank records in a file except for few columns

I have a file with the following format: X|High|2|GIC|DM||XHM|||6 Months X|Moderate|2|GIC|DM||XHM|||6 Months X|High|2|GCM|DM||XSF|||6 Months X|Med|2|GCM|DM||XSF|||6 Here there are ten columns but I need to print rows having blank records in any of the rows (except for 6th,8th and 9th... (10 Replies)
Discussion started by: chatwithsaurav
10 Replies

10. Shell Programming and Scripting

To group records in the file in UNIX

Hi All, I am using RHEL 6.9. I got a requirement to group the records in a file.The file content as shown below. #### FAILED JOBS IN XXX ##### 1> ABCD failed in the project XXX 2> HJK Job is in compiled state in the project XXX 3> ILKD failed in the project XXX 4> DFG failed in the... (5 Replies)
Discussion started by: ginrkf
5 Replies
DROP 
AGGREGATE(7) PostgreSQL 9.2.7 Documentation DROP AGGREGATE(7) NAME
DROP_AGGREGATE - remove an aggregate function SYNOPSIS
DROP AGGREGATE [ IF EXISTS ] name ( argtype [ , ... ] ) [ CASCADE | RESTRICT ] DESCRIPTION
DROP AGGREGATE removes an existing aggregate function. To execute this command the current user must be the owner of the aggregate function. PARAMETERS
IF EXISTS Do not throw an error if the aggregate does not exist. A notice is issued in this case. name The name (optionally schema-qualified) of an existing aggregate function. argtype An input data type on which the aggregate function operates. To reference a zero-argument aggregate function, write * in place of the list of input data types. CASCADE Automatically drop objects that depend on the aggregate function. RESTRICT Refuse to drop the aggregate function if any objects depend on it. This is the default. EXAMPLES
To remove the aggregate function myavg for type integer: DROP AGGREGATE myavg(integer); COMPATIBILITY
There is no DROP AGGREGATE statement in the SQL standard. SEE ALSO
ALTER AGGREGATE (ALTER_AGGREGATE(7)), CREATE AGGREGATE (CREATE_AGGREGATE(7)) PostgreSQL 9.2.7 2014-02-17 DROP AGGREGATE(7)
All times are GMT -4. The time now is 04:47 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy