Sponsored Content
Full Discussion: Set of 2 records as one unit
Top Forums Shell Programming and Scripting Set of 2 records as one unit Post 302558742 by PG3 on Sunday 25th of September 2011 06:36:26 AM
Old 09-25-2011
Scrutinizer,

Thanks a bunch for making yourself clear in you are doing here but I dont get it completely. I think I should pick up the Kernighan's book on Awk.

First things first, "Thanks for the help".

At any rate, 2 new challenges. When I run the newly pasted, line, it doesnt run and errors with the following message and Im pasting directly over here. Im running bash btw.

Also, how do I run this same line for 3 RECORDS not 2 RECORDS and here is the real business scenario for this. Lets say the transaction is coming from a restaurant, it has initial authorization amount as Authorized amount and then the customer lets say is nice enough to add a gratuity(tip) to it. So when the merchant presents the transaction to the bank, then the final amount would be different from amount Authorized. So, how do I reconcile these three sets of records ?

Please advise.

regards,
PGonzalez.
Code:
/Users/PGonzalez 02:53:07 $awk '/AUTH/{A[$NF]=$0}/FINAL/&&A[$NF]{print $0 RS A[$NF];delete A[$NF]}' ADCC
11233 19.00($) FINAL 339 
11233 23.20($) AUTH 339
11234 349.84($) FINAL 42332 
11234 349.84($) AUTH 42332 
11238 763.94($) FINAL 843883
11238 763.94($) AUTH 843883
/Users/PGonzalez 02:54:33 $
/Users/PGonzalez 02:54:43 $awk '/AUTH/{A[$NF]=$0}/FINAL/&&A[$NF]{print A[$NF] RS $0]}' ADCC
awk: extra ] at source line 1
 context is
	/AUTH/{A(NF)]=$0}/FINAL/&&A(NF)]{print A(NF)] RS >>>  $0] <<< 
awk: syntax error at source line 1
awk: illegal statement at source line 1
	extra ]
/Users/PGonzalez 03:26:35 $


Last edited by Scott; 09-25-2011 at 08:31 AM.. Reason: Code tags
 

9 More Discussions You Might Find Interesting

1. 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

2. Shell Programming and Scripting

Getting MAC from GPS unit

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

3. 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

4. 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

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

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

7. 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

8. 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

9. 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
RPC_CLNT_AUTH(3)					   BSD Library Functions Manual 					  RPC_CLNT_AUTH(3)

NAME
auth_destroy, authnone_create, authsys_create, authsys_create_default -- library routines for client side remote procedure call authentica- tion LIBRARY
Standard C Library (libc, -lc) SYNOPSIS
#include <rpc/rpc.h> void auth_destroy(AUTH *auth); AUTH * authnone_create(void); AUTH * authsys_create(const char *host, const uid_t uid, const gid_t gid, const int len, const gid_t *aup_gids); AUTH * authsys_create_default(void); DESCRIPTION
These routines are part of the RPC library that allows C language programs to make procedure calls on other machines across the network, with desired authentication. These routines are normally called after creating the CLIENT handle. The cl_auth field of the CLIENT structure should be initialized by the AUTH structure returned by some of the following routines. The client's authentication information is passed to the server when the RPC call is made. Only the NULL and the SYS style of authentication is discussed here. Routines auth_destroy() A function macro that destroys the authentication information associated with auth. Destruction usually involves deallocation of private data structures. The use of auth is undefined after calling auth_destroy(). authnone_create() Create and return an RPC authentication handle that passes nonusable authentication information with each remote procedure call. This is the default authentication used by RPC. authsys_create() Create and return an RPC authentication handle that contains AUTH_SYS authentication information. The host argu- ment is the name of the machine on which the information was created; uid is the user's user ID; gid is the user's current group ID; len and aup_gids refer to a counted array of groups to which the user belongs. authsys_create_default() Call authsys_create() with the appropriate arguments. SEE ALSO
rpc(3), rpc_clnt_calls(3), rpc_clnt_create(3) BSD
May 7, 1993 BSD
All times are GMT -4. The time now is 07:10 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy