LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 08-28-2008, 11:40 PM   #1
raghu123
Member
 
Registered: May 2008
Posts: 34

Rep: Reputation: 15
Appending a string to columns in a file


Hi........

I hav a file like this...
1A4G:A 1A4G:B 0.2
1A4G:A 1CT1:F 3.2
1A4G:A 1CT1:G 3.4
1A4G:A 1DBN:B 3.2
1A4G:A 1F31:A 3.1
1A4G:A 1FV2:A 4.1

after the 1st and 2nd field's last charecter ends, i wan ".PDB" to be added to both 1st and 2nd fields.....(not to the 3rd field)
means.....
1A4G:A.PDB 1A4G:B.PDB 0.2
1A4G:A.PDB 1CT1:F.PDB 3.2
1A4G:A.PDB 1CT1:G.PDB 3.4

i know the logic like using the strcat in C.....
But thought shell can be easier
So.....
Plz suggest.....
 
Old 08-29-2008, 12:40 AM   #2
Matir
LQ Guru
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Debian, Arch
Posts: 8,507

Rep: Reputation: 128Reputation: 128
Try something like:
Code:
awk '{print $1 ".PDB " $2 ".PDB " $3}' INPUT > OUTPUT
Replace INPUT and OUTPUT with your files.
 
Old 08-29-2008, 01:19 AM   #3
raghu123
Member
 
Registered: May 2008
Posts: 34

Original Poster
Rep: Reputation: 15
Thanq .its working good.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
how to append columns form a column file in another file adam_blackice Programming 4 09-17-2007 11:33 PM
Appending to a log file (C++) itz2000 Programming 4 10-27-2006 09:57 AM
appending a file circuit_girl Programming 8 10-01-2006 11:00 AM
Appending a string to a file JStew Linux - General 13 03-04-2003 03:48 PM
sending a mail appending a file saavik Linux - Newbie 4 07-12-2002 03:50 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:54 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration