Help identifying transactions with no detail lines


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Help identifying transactions with no detail lines
# 1  
Old 05-18-2010
CPU & Memory Help identifying transactions with no detail lines

Wondering if someone can help with my task of identifying missing detail lines in transactions.

I have a flat file that contains transaction header, transaction detail, and transaction trailer lines. These lines are identified with a 5-character line identifier "THEAD", "TDETL", and "TTAIL" at the beginning of the line. Similar to this:

Code:
THEAD000000000200000000
TDETL0000000003000000Good
TTAIL0000000004000000

How can I identify which transactions have missing TDETL lines?
In other words, a missing TDETL transaction is one where there is a THEAD and then TTAIL right after on the next line without a TDETL line in between. Here is one such example:

Code:
THEAD000000000200000000
TTAIL0000000003000000

In those conditions, I'd like to print out the THEAD lines to a text file as well as the file name that the missing TDETL transaction was found in as I will be running this script against 1000s of files.

Is SED or GREP the proper tools to use? What would be the best way to go about this?

Last edited by vgersh99; 05-18-2010 at 06:56 PM.. Reason: code tags, please!
# 2  
Old 05-18-2010
Code:
nawk '/^THEAD/{h=$0;d="";next} /^TDETL/{d=$0} !d{print FILENAME, h}' myFiles

This User Gave Thanks to vgersh99 For This Post:
# 3  
Old 05-18-2010
Quote:
Originally Posted by vgersh99
Code:
nawk '/^THEAD/{h=$0;d="";next} /^TDETL/{d=$0} !d{print FILENAME, h}' myFiles

Works very well. Thank you very much.

Just so I understand: what you're doing is looking for the line to start with "THEAD", once found save the THEAD line in variable h, reset the d variable to blank, and then go to the next line in which case you will then check that it begins with "TDETL", if it does, save the TDETL line in variable d, otherwise print the filename of the file and then variable h (which will be the THEAD line).

Is this right? Please correct me if I'm wrong or if you can explain it in better terms so that I learn.
Login or Register to Ask a Question

Previous Thread | Next Thread

7 More Discussions You Might Find Interesting

1. Solaris

Tape Drive Detail

Hi, I am using HP Ultarium Tape drive to backup my oracle DB. Is that any command to identify the tape serial number or any other tape details that inserted into the tape drive? (2 Replies)
Discussion started by: tharmendran
2 Replies

2. UNIX for Advanced & Expert Users

Need to get the time difference for all the transactions in a day

Hello Experts, I need to evaluate my API performance, so need a script to get the time difference for all the transaction that has gone through my application in a day. The challenge is the multi threaded logs, so I cant just get all the Telephone Numbers and check the entering and existing... (5 Replies)
Discussion started by: samjna
5 Replies

3. Shell Programming and Scripting

Script to take count of transactions

Hello All, I have written a script which i run on admin server to display the count of transaction on rest of the service blades. here is the code s='' if then s=$1 fi if then TPS=`on tswebpxmp1 snmpget -c public -v 2c 127.0.0.1:1610 1.3.6.1.4.1.12702.9.2.6.2.0 |... (0 Replies)
Discussion started by: Siddheshk
0 Replies

4. Shell Programming and Scripting

Append transaction header lines to same transaction's detail lines

Hi guys, I was wondering if someone can give me a hand in helping me append transaction header line in a file at the end of the transaction detail lines. Basically, I have a file that looks like this: FHEAD File1 THEAD TRANS1-blah TDETL HI1 TDETL HI2 TDETL HI3 TTAIL TRANS1-blah THEAD... (3 Replies)
Discussion started by: rookie12
3 Replies

5. Cybersecurity

Check login detail

As a root user i switch to a different user say "oratest". I would like to know the details like at what time did the switch ( su - oratest ) happen. Are there any logs to check this Thanks. (2 Replies)
Discussion started by: jjoy
2 Replies

6. UNIX for Advanced & Expert Users

what does metaroot in detail?

I have a problem with a submirror of the root filesystem, in the procedure in order to unmirror the FS say: metadetach -f d0 d20 metaroot c0t0d0s0 but, in my system the metaroot cause a segmentation fault coredump. I knew that the command modify the /etc/system and the /etc/vfstab. I try... (3 Replies)
Discussion started by: hugo_perez
3 Replies

7. UNIX for Dummies Questions & Answers

Getting detail out of a log file...

I'd like to peruse a log file and from it generate another file from the first instance of "Jul 11" to the first instance of "Jul 18" within the log file. (3 Replies)
Discussion started by: Cameron
3 Replies
Login or Register to Ask a Question