How to add trailer record at the end of the flat file in the unix ksh shell scripting?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to add trailer record at the end of the flat file in the unix ksh shell scripting?
# 1  
Old 05-18-2012
How to add trailer record at the end of the flat file in the unix ksh shell scripting?

Hi,

How to add trailer record at the end of the flat file in the unix ksh shell scripting

can you please let me know the procedure

Regards
Srikanth
# 2  
Old 05-18-2012
what is the desired output?
like this?
Code:
# cat file
test
# awk 'BEGIN{X="Record"}1;END{print X}' file
test
Record

# 3  
Old 05-18-2012
Can you try like...
Code:
 awk '{print $0,"\n000000"}' test1.txt

# 4  
Old 05-18-2012
You could just append a line to the file...

Code:
echo "trailer record" >> filename

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How can I extract digits at the end of a string in UNIX shell scripting?

How can I extract digits at the end of a string in UNIX shell scripting or perl? cat file.txt abc_d123_4567.txt A246_B789.txt B123cc099.txt a123_B234-012.txt a13.txt What can I do here? Many thanks. cat file.txt | sed "s/.txt$//" | ........ 4567 789 099 012 13 (11 Replies)
Discussion started by: mingch
11 Replies

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

3. Shell Programming and Scripting

awk command to omit trailer record in a file

I am trying to omit the trailer record in a variable width file I tried using awk 'NR >1 { print prev } { prev = $0 }' filename The above command is giving output but somehow it is trimming columns from the record. For example if my record has columns A,B,C,D The awk gives output as A,B,C ... (4 Replies)
Discussion started by: abhilashnair
4 Replies

4. Shell Programming and Scripting

Need a ksh script for adding the space at the end of record in a flat file

Hi, I need a ksh script for the below requirement: i have a Delimited flat file with 200 records delimiter is '|~|' i need a script to insert space at the end if the record is ending with delimiter '|~|' if it didnt end with delimiter it should not append space. Example: ram|~|2|~| ... (16 Replies)
Discussion started by: srikanth_sagi
16 Replies

5. Shell Programming and Scripting

csv file - adding total to a trailer record

Hi, I have a script which creates and modifies a csv file. I have managed to do everything I need to do apart from 1 thing. I need to append a trailer record to the file. I need this line to hold the total of an entire column of the csv file (skipping the 1st line which is a header). Can... (2 Replies)
Discussion started by: mcclunyboy
2 Replies

6. Shell Programming and Scripting

how to add blank spaces at the end of every record in a file.

hi, Does anyone has any idea in adding few blank spaces at the end of every record in a file. Eg: file.txt Baby Boy Kim 1234 Baby Boy Vik 1334 Desired output:- output.txt Baby Boy Kim 1234 Baby Boy Vik 1334 I want to add 10 blank spaces at the end every record in file.txt (3 Replies)
Discussion started by: techmoris
3 Replies

7. Shell Programming and Scripting

Need UNIX shell scripting end to end information

Hi, I would like to learn shell scripting in UNIX. Can any one please give me the support and share the information/documents with me. If any documents please post it to aswanikumar_nimmagadda@yahoo.co.in Thanks in advance...!!! (3 Replies)
Discussion started by: aswani_n
3 Replies

8. Shell Programming and Scripting

add a line at the end of a file using shell scripting

Hi All , I am new to shell scripting. i have a shell script(which is executed as a super user) , i want to it to do one more job for me. ie mounting a directory over other using lofs . i have done it manually using 1) using mount command mount -F lofs /export/home/dju /dju 2)... (4 Replies)
Discussion started by: meet123321
4 Replies

9. Shell Programming and Scripting

MERGE 13 files and add the file name at the end of each record

Hi Gurus, I have 13 comma(,) seperated files that i have to merge and create a single file which has file name attached at th end of each record in the out put file. Can any one please help me with writing a unix script with this issue? test1.dat BIG ID,Local ID,Bond... (2 Replies)
Discussion started by: vkr
2 Replies

10. UNIX for Dummies Questions & Answers

Removing trailer from a flat file!!!

Hi, I get some flat files with trailer which gives the totol records count and i want to remove the trailer from the file. i used the following command it works fine with a single file. cat file_name | grep -v 'Total records:' > file1 mv file file_name But i dont know how to remove the... (12 Replies)
Discussion started by: kumarsaravana_s
12 Replies
Login or Register to Ask a Question