LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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 10-09-2007, 01:49 AM   #1
athreyavc
Member
 
Registered: May 2004
Location: bangalore
Distribution: Cent OS, Ubuntu
Posts: 116

Rep: Reputation: 15
file formatting via shell scripting


Hi All ,

I have 2 files

file 1

ram 25y BAL
sham 24y NY

file 2

100
200

I want a resultant file that should be in this format

ram 25y BAL 100
ram 25y BAL 200

can this be done in shell scripting ?

Please help me out

Best Regatds,

Athreya
 
Old 10-09-2007, 02:51 AM   #2
radoulov
Member
 
Registered: Apr 2007
Location: Milano, Italia/Варна, България
Distribution: Ubuntu, Open SUSE
Posts: 212

Rep: Reputation: 38
Quote:
Originally Posted by athreyavc View Post
I have 2 files

file 1

ram 25y BAL
sham 24y NY

file 2

100
200

I want a resultant file that should be in this format

ram 25y BAL 100
ram 25y BAL 200
[...]
Assuming the output should be:

Code:
ram 25y BAL 100
sham 24y NY 200
Code:
paste -d" " file1 file2
otherwise (if the output should be really as shown):

Code:
printf "$(read a b c<file1;printf "%s" "$a $b $c") %s\n" $(<file2)

Last edited by radoulov; 10-09-2007 at 02:57 AM.
 
Old 10-09-2007, 03:55 AM   #3
athreyavc
Member
 
Registered: May 2004
Location: bangalore
Distribution: Cent OS, Ubuntu
Posts: 116

Original Poster
Rep: Reputation: 15
Thank you radoulov

That indeed helped a lot , I did know the option with the paste command

Thanks a million

Best Regards,

Athreya
 
  


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
[SOLVED] shell scripting: How can I increment a file by number dv502 Programming 11 08-27-2010 08:43 AM
shell scripting: "formatting" issue with text files eur0dad Programming 3 08-17-2006 10:50 AM
Inserting lines into a file through shell scripting false-hopes Linux - General 1 10-22-2005 11:39 AM
Reading text from a file using shell scripting. mrobertson Programming 11 06-29-2005 12:12 PM
Shell scripting from java file karthiknataraj Linux - General 1 02-08-2003 04:47 AM

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

All times are GMT -5. The time now is 07:51 AM.

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