Set of 2 records as one unit


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Set of 2 records as one unit
# 8  
Old 09-25-2011
Hi, firstly,there was a superfluous ']' in the code, I took it out in the post...
To understand awk, perhaps it helps to realize that awk statements in the main section implicitly work on a per line basis, so they are executed as if in a loop and are processing every line in the file.

Could you give an example of such a transaction log with 3 records?
# 9  
Old 09-25-2011
Scrutinizer,

Yes, after a second glance, I realized the extra "]" and when I took out, it just ran well.

Sure here is the sample set of records with 3 records instead of two.
Code:
11393 18.77(E) AUTH 43034
11393 23.77(E) PRES 43034
11393 23.77(E) SETT 43034


11571 25.03(E) AUTH 39840002
11571 34.53(E) PRES 39840002
11571 34.53(E) SETT 39840002


11884 76.29($) AUTH 4954884
11884 90.29($) PRES 4954884
11884 90.29($) SETT 4954884

and out of these, I just want the Account numbers as below and I dont want anymore details(& I just realized that now)
Code:
11393
11571
11884

as these are the values that are stored in Oracle and Im just trying to create a look up file so that sqlloader can insert these records into the db.

Finally, thanks a bunch on your help.

regards,
PGonzalez.

Last edited by Scott; 09-25-2011 at 08:30 AM.. Reason: Code tags
# 10  
Old 09-25-2011
How about:
Code:
awk '/SETT/{print $1}' infile

If SETT is the final transaction (I don't know)
Or do you still need to check something?
# 11  
Old 09-26-2011
Scrutinizer,

Thank you for the reply.

To make it a bit more clear, SETT is the final part of the puzzle & is an abbreviation for SETTLEMENT. These three records have to looked at together and if any of these three i.e., AUTH(AUTHORIZATION), PRES(PRESENTMENT) & SETT(SETTLEMENT) are not there then it is considered as INCOMPLETE record. We report only on COMPLETE SETS and only when you find all these three transactions then we would want to see that ACCOUNT NUMBER.

So, if you can just print only the account numbers that have all these three types of records, then we are good.

I hope Im clear now and in case of questions, please feel free to revert back to me and I shall respond back right away.

Thank you for the initiative & your BIG HELP.

regards,
PG.
# 12  
Old 09-26-2011
Hi try this:
Code:
awk '/AUTH/{A[$NF]++} /PRES/{P[$NF]++} /SETT/&& A[$NF] && P[$NF]{print $1}' infile

or
Code:
 awk '/AUTH/{A[$NF]++} /PRES/{P[$NF]++} /SETT/&& A[$NF] && P[$NF]{print $1; delete A[$NF]; delete P[$NF]}' infile

for the more memory efficient version...

These will print the same account number multiple times if it has more than one transaction.
This User Gave Thanks to Scrutinizer For This Post:
# 13  
Old 09-26-2011
Scrutinizer,

You truly are exalted !

regards,
PGonzalez.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Simple unit script

Hello guys this is my first post in this forum. Since now ive been passive an ive only been looking for existing information. Now I could use specific help on a UNIX script i want to make that would: 1. Take 1-3 arguments. 2. Display the contents of its arguments, formatted as follows:... (7 Replies)
Discussion started by: banzomaster
7 Replies

2. Shell Programming and Scripting

Compare two files with different number of records and output only the Extra records from file1

Hi Freinds , I have 2 files . File 1 |nag|HYd|1|Che |esw|Gun|2|hyd |pra|bhe|3|hyd |omu|hei|4|bnsj |uer|oeri|5|uery File 2 |nag|HYd|1|Che |esw|Gun|2|hyd |uer|oi|3|uery output : (9 Replies)
Discussion started by: i150371485
9 Replies

3. HP-UX

Load average unit

Hi, On load average graph, unit is 100m, 200m, 300...800m. I don't understand what it means. Thx for helping (3 Replies)
Discussion started by: Michenux
3 Replies

4. Shell Programming and Scripting

Adding existing set of records in the same file

I have a file with 50,000 records in it, i have a requirement to use the same 50,000 records and add them 4 times to the same file to make a total of 200,000 records. I was wondering how to do this using ksh. Any help is greatly appreciated. (2 Replies)
Discussion started by: vpv0002
2 Replies

5. Shell Programming and Scripting

extract set of matching records

i have a pipe delimited file with records spread in many lines. i need to extract those records 1)having X in beginning of that record 2)and having at least one Y in beginning before other record begins eg: X|Rec1| A|Rec1| Y|Rec1| X|Rec2| Y|Rec2| Z|Rec3| X|Rec4| M|Rec4| ... (4 Replies)
Discussion started by: finder255
4 Replies

6. Shell Programming and Scripting

Based on num of records in file1 need to check records in file2 to set some condns

Hi All, I have two files say file1 and file2. I want to check the number of records in file1 and if its atleast 2 (i.e., 2 or greater than 2 ) then I have to check records in file2 .If records in file2 is atleast 1 (i.e. if its not empty ) i have to set some conditions . Could you pls... (3 Replies)
Discussion started by: mavesum
3 Replies

7. UNIX for Dummies Questions & Answers

seperating records with numbers from a set of numbers

I have two files one (numbers file)contains the numbers(approximately 30000) and the other file(record file) contains the records(approximately 40000)which may or may not contain the numbers from that file. I want to seperate the records which has the field 1=(any of the number from numbers... (15 Replies)
Discussion started by: Shiv@jad
15 Replies

8. Shell Programming and Scripting

Getting MAC from GPS unit

Never mind i got the answer thanks., (0 Replies)
Discussion started by: deaconf19
0 Replies

9. UNIX for Dummies Questions & Answers

Cutting a limited or given set of records in a datbase

I need to select "cut" a certain number of records in a database. ie. records 20 to 25. Help (4 Replies)
Discussion started by: Iaf_user
4 Replies
Login or Register to Ask a Question