Adding Header and Trailer records to a appended file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Adding Header and Trailer records to a appended file
# 1  
Old 09-26-2011
Adding Header and Trailer records to a appended file

How can we a shell script and pass date parameters .I have 3 files comming from Datastage with |" delimited
I need append 3 files as above: File1:
Code:
P0000|"47416954|"AU|"000|"INS|"0000|"|"20060601|"99991231|"|"|"|"|"01

File 2:
Code:
P0001|"47416954|"AU|"000|"INS|"0001|"|"20060501|"99991231|"|"|"|"|"4210|"4210|"1|"2S|"GB|"|"4211|"8M

File 3:
Code:
P0002|"47416954|"AU|"000|"INS|"0002|"|"20060601|"99991231|"|"|"|"|"ALLY-POLLARD|"|"LEILA|"|"LEILA|"00|"2|"2|"19760411|"GB|"|"1|"20040828|"|"|"|"JE397813B

After append 3 files i need add Header and trailer for the single file
Header Should have following inforamtion:
Code:
RECTYP|"CLientid|"Cleint Name|"email|"RunDate|"RunTime

Rundate:YYYYMMDD format need to be passed
Run Time: HHMMSS in 24 hour format should be passed

Trailer Record:
Code:
RECTYP|"RECORD COUNT

Sample output should be like this
Code:
HEADR|"GVAADP|"ID |"MANI|"|"OT20060403|"20060403|"050020
P0000|"47416954|"AU|"000|"INS|"0000|"|"20060601|"99991231|"|"|"|"|"01
P0001|"47416954|"AU|"000|"INS|"0001|"|"20060501|"99991231|"|"|"|"|"4210|"4210|"1|"2S|"GB|"|"4211|"8M
P0002|"47416954|"AU|"000|"INS|"0002|"|"20060601|"99991231|"|"|"|"|"POLLARD|"|"LEILA|"|"LEILA|"00|"2|"2|"19760411|"GB|"|"1|"20040828|"|"|"|"JE397813B
TRAIL|"3

[mod]
Please use code tags when posting data and code samples!
[/mod

Last edited by vgersh99; 09-26-2011 at 03:56 PM.. Reason: please use code tags!
# 2  
Old 09-26-2011
What is the information in the header supposed to be generated from?

Everything but the date calculation sounds easy:

Code:
( echo HEADER
cat file1 file2 file3
echo FOOTER ) > outfile

# 3  
Old 09-26-2011
Quote:
Originally Posted by Corona688
What is the information in the header supposed to be generated from?

Everything but the date calculation sounds easy:

Code:
( echo HEADER
cat file1 file2 file3
echo FOOTER ) > outfile

How can we pass date and time in the header and record count in the Trailer record
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Removing Header and Trailer record of a EBCDIC file

I have a EBCDIC multi layout file which has a header record which is 21 bytes, The Detail records are 2427 bytes long and the trailer record is 9 bytes long. Is there a command to remove the header as well as trailer record and read only the detail records while at the same time not altering... (1 Reply)
Discussion started by: abhilashnair
1 Replies

2. Shell Programming and Scripting

Split and add header and trailer from input file

I need to split the file based on pattern from position 34-37 while retaining the header and trailer records in each individual split file Also is it possible to output the TOM and PAT records in the same output file ? I need the output file names same as xyz_pattern_Datetimestamp.txt ... (23 Replies)
Discussion started by: techedipro
23 Replies

3. Shell Programming and Scripting

Verify the header and trailer in file

please see my requirement, I hope I am clear. (9 Replies)
Discussion started by: mirwasim
9 Replies

4. Shell Programming and Scripting

Script to validate file header and trailer

Hi, I need a script that validates a file header/detail/trailer. File layout is: Header - Rec_Type|File_name|File_Date Detail - Rec_Type|field1|field2|field3... Trailder - Rec_Type|File_name|File_Date|Record_count Sample Data: HDR|customer_data.dat|20120709... (7 Replies)
Discussion started by: ash_sh
7 Replies

5. UNIX for Dummies Questions & Answers

oneliner for adding header and trailer

for example, i have a file with below content: 123413 866688 816866 818818 i want the output as: This is header 123413 866688 816866 818818 This is trailer i am able to achieve it using a bash script. (2 Replies)
Discussion started by: pandeesh
2 Replies

6. UNIX for Dummies Questions & Answers

Adding header and trailer into a file

Hi, I want to add the below Header to all the files in sequence File1,File2,File3...etc "ABC,<number of chracter in the file>" e,g - If File1 is as below pqrstuvdt abcdefgh then I want to add the above header into it ,So that File1 becomes as below ABC,17 pqrstuvdt abcdefgh ... (9 Replies)
Discussion started by: spari2
9 Replies

7. Shell Programming and Scripting

improve performance - replace $\| with $#@ and remove header and trailer records

Hi All, In my file i need to remove header and trailer records which comes in 1st line and last line respectively. After that i need to replace '$\|' with '$#@'. I am using sed command for this and its taking lot of time. Is there any other command which can be used to improve performance? ... (1 Reply)
Discussion started by: HemaV
1 Replies

8. Shell Programming and Scripting

Removing Header & Trailer from a file

Hi All, I am karthik. I am new to this forum. I have one requirement. I have a file with header and footer. Header may be like HDR0001 or FILE20090110 (Assume it is unknown so far, but i am sure there is a header in the file) likewise file has the trailer too. I just... (7 Replies)
Discussion started by: karthi_gana
7 Replies

9. Shell Programming and Scripting

Merge text files while combining the multiple header/trailer records into one each.

Situation: Our system currently executes a job (COBOL Program) that generates an interface file to be sent to one of our vendors. Because this system processes information for over 100,000 employees/retirees (and growing), we'd like to multi-thread the job into processing-groups in order to... (4 Replies)
Discussion started by: oordonez
4 Replies

10. Shell Programming and Scripting

Count No of Records in File without counting Header and Trailer Records

I have a flat file and need to count no of records in the file less the header and the trailer record. I would appreciate any and all asistance Thanks Hadi Lalani (2 Replies)
Discussion started by: guiguy
2 Replies
Login or Register to Ask a Question