General
cancel
Showing results for 
Search instead for 
Did you mean: 

Need urgent Help, How to modify file using awk or sed??

 
SOLVED
Go to solution
Highlighted
Advisor

Need urgent Help, How to modify file using awk or sed??

Hi to all,

I need to relese a script by today itself. please help me to do this.

I have a big file lets say 65 thousand lines. it is a tab seperated text file. i need to add one more columne at the end of every line ( tab seperated). the value of that column is the first column of the first line.

example:

Inputfile:

NY^hhhhh^hhhhh^kkkkk^gggg
hhh^jjjjj^9999^44444
888^hhhh^443444^hhhhhh

Output file

NY^hhhhh^hhhhh^kkkkk^gggg^NY
hhh^jjjjj^9999^44444^NY
888^hhhh^443444^hhhhhh^NY

here '^' represent tab character.


please help me ASAP.

vivek S.
viveks@fox.com

2 REPLIES 2
Highlighted
Esteemed Contributor
Solution

Re: Need urgent Help, How to modify file using awk or sed??

Well a little snippet of code:

export FIELD=`head -1 filename| awk ' { print $1 } '
awk -v FIELD=$FIELD '{ FS = "\t" } { print $0, FIELD } ' filename.new

should handle the job for you.

hth
mark
Highlighted
Advisor

Re: Need urgent Help, How to modify file using awk or sed??

Thanks Mark.