Simpler Navigation for Servers and Operating Systems - Please Update Your Bookmarks
Completed: a much simpler Servers and Operating Systems section of the Community. We combined many of the older boards, so you won't have to click through so many levels to get at the information you need. Check the consolidated boards here as many sub-forums are now single boards.
If you have bookmarked forums or discussion boards in Servers and Operating Systems, we suggest you check and update them as needed.
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
Vivek_3
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
Mark Fenton
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
Vivek_3
Advisor

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

Thanks Mark.