Today (Saturday) We will make some minor tuning adjustments to MySQL.

You may experience 2 up to 10 seconds "glitch time" when we restart MySQL. We expect to make these adjustments around 1AM Eastern Daylight Saving Time (EDT) US.


Add header and footer with record count in footer


Login or Register to Reply

 
Thread Tools Search this Thread
# 1  
Add header and footer with record count in footer

This is my file(Target.txt)
Code:
name|age|locaction
abc|23|del
xyz|24|mum
jkl|25|kol


The file should be like this
Code:
1|03252012
1|name|age|location
2|abc|23|del
2|xyz|24|mum
2|jkl|25|kol
2|kkk|26|hyd
3|4


Column 1 is row indicator
for row 1 and 2, column indicator is 1,for data rows its 2 and for footer its 3.
for footer the record count is is required.

Please help me how to achive it

Last edited by Franklin52; 03-25-2012 at 07:48 AM.. Reason: Please use code tags for data and code samples, thank you
# 2  
I assume the first row is the current date.
Code:
awk 'BEGIN{"date +%m%d%Y" | getline first; print "1|" first} {if(NR>1){print "2|"$0}else{print "1|"$0} ++c}END{print "3|"c}' infile

Login or Register to Reply

|
Thread Tools Search this Thread
Search this Thread:
Advanced Search

More UNIX and Linux Forum Topics You Might Find Helpful
File Row Line Count without Header Footer
gagan8877
Hi There! I am saving the file count of all files in a directory to an output file using: wc -l * > FileCount.txt I get: 114 G4SXORD 3 G4SXORH 0 G4SXORP 117 total But this count includes header and footer. I want to subtract 2 from the count and get ...... UNIX for Dummies Questions & Answers
7
UNIX for Dummies Questions & Answers
Header and Footer...
suresh_target
Hi All, I need to write a script that In my file I have to check header and footer records are available or not. If it is available I have to run the script, otherwise I should not. But current script it is checking only the data inside the script. It is avoiding to check Header and Footer...... Shell Programming and Scripting
1
Shell Programming and Scripting
How to add header and footer?
ken002
Hi, Guys, I want add header and footer in a file. I can add footer using following command: echo "Footer" >>file. I don't know how to add header. Thanks in advance... Shell Programming and Scripting
4
Shell Programming and Scripting
Split large file and add header and footer to each small files
ashish4422
I have one large file, after every 200 line i have to split the file and the add header and footer to each small file? It is possible to add different header and footer to each file?... Shell Programming and Scripting
7
Shell Programming and Scripting
Need to Chop Header and Footer record from input file
coolbudy
Hi, I need to chope the header and footer record from an input file and make a new output file, please let me know how i can do it in unix.thanks.... Shell Programming and Scripting
4
Shell Programming and Scripting

Featured Tech Videos