Append transaction header lines to same transaction's detail lines


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Append transaction header lines to same transaction's detail lines
# 1  
Old 06-17-2010
Java 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:
Code:
FHEAD File1
THEAD TRANS1-blah
TDETL HI1
TDETL HI2
TDETL HI3
TTAIL TRANS1-blah
THEAD TRANS2-blah
TDETL HELLO1
TDETL HELLO2
TTAIL TRANS2-blah
FTAIL File1

And I'm looking to have something like this:
Code:
TDETL HI1, THEAD TRANS1-blah
TDETL HI2, THEAD TRANS1-blah
TDETL HI3, THEAD TRANS1-blah
TDETL HELLO1, THEAD TRANS2-blah
TDETL HELLO2, THEAD TRANS2-blah

Basically, I want to have the THEAD line of a transaction appended at the end of all of the same transaction's TDETL line. Any idea?
# 2  
Old 06-17-2010
Code:
$ perl -nle 'if ($a == 0 && $_ !~ /^F/)  { push @x, $_; $a=1; next; }
             if ($a == 1 && $_ !~ /^TT/) { print "$_, @x";          }
          elsif ($a == 1 && $_ =~ /^TT/) { @x=(), $a=0;             }' file

# 3  
Old 06-17-2010
Code:
awk '/THEAD/ {a=$0} /TDETL/ {print $0 "," a}' urfile

# 4  
Old 06-18-2010
perl

Code:
my $tmp;
while(<DATA>){
	chomp;
	if(/THEAD/){
		$tmp=$_;
		next;
	}
	elsif(/TDETL/){
		print $_," ",$tmp,"\n";
	}
}
__DATA__
FHEAD File1
THEAD TRANS1-blah
TDETL HI1
TDETL HI2
TDETL HI3
TTAIL TRANS1-blah
THEAD TRANS2-blah
TDETL HELLO1
TDETL HELLO2
TTAIL TRANS2-blah
FTAIL File1

This User Gave Thanks to summer_cherry For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. AIX

Transaction based resources

How do I determine the resources needed based on volume of transactions. By resources I mean, the cores, memory etc. Is there a way to arrive at that value? (1 Reply)
Discussion started by: ggayathri
1 Replies

2. Programming

Difference between BEGIN TRANSACTION & START TRANSACTION?

What's the difference between BEGIN TRANSACTION vs START TRANSACTION? Also goes for COMMIT TRANSACTION vs COMMIT? (0 Replies)
Discussion started by: dan139
0 Replies

3. Shell Programming and Scripting

Process only files which have completed in transaction

Hi , I have a situation where I have to Process files ( move , edit or rename ) in a folder ..... This folder is a FTP folder and Files keep coming in when they are available ... So I should perform my actions on those which which completed transaction .. . Is there a way to identify a... (3 Replies)
Discussion started by: chillblue
3 Replies

4. UNIX for Dummies Questions & Answers

Rolling back SQL transaction

Can some one help me related to .sql file issue. I have a .sqlfile and tried to read the file thru unix. In the .sqlfile I have error rows as well and when error comes I dont want to proceed further and need to roll back all the transactions. sample .sql file below insert into test... (2 Replies)
Discussion started by: sri_aue
2 Replies

5. Solaris

Concept of ZFS transaction semantics

HI, Can anyone explain me the concept behind ZFS transactional semantics (either a transaction is entirely commited or it is not)? so data and disk failures are reduced. (5 Replies)
Discussion started by: Revathi@1
5 Replies

6. Linux

YUM HANGS AT RUNNING TRANSACTION TEST

Hi When i trying to update using yum, hangs at Running transaction test. # yum update yum Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * addons: ftp.oss.eznetsols.org * extras: ftp.oss.eznetsols.org * base: ftp.oss.eznetsols.org * updates:... (2 Replies)
Discussion started by: anil8103
2 Replies

7. UNIX and Linux Applications

Got Errors while sending a transaction through ESB

We are getting below error when processing a transaction through ESB. I work for SOA admin and checked the JCA connection is working fine also code also working fine in other envs. An unhandled exception has been thrown in the ESB system. The exception reported is:... (1 Reply)
Discussion started by: KuldeepSinghTCS
1 Replies

8. Shell Programming and Scripting

average transaction time

Hi all, I have large daily log file(s) that hold the times for requests and responses on different system requests. What I want to do is work out average transaction times for the day (one log = one day). The problem I'm having is figuring out how to skip rows, i've sorted the output by uniq... (2 Replies)
Discussion started by: nhatch
2 Replies
Login or Register to Ask a Question