LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   file formatting via shell scripting (https://www.linuxquestions.org/questions/programming-9/file-formatting-via-shell-scripting-590450/)

athreyavc 10-09-2007 01:49 AM

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

radoulov 10-09-2007 02:51 AM

Quote:

Originally Posted by athreyavc (Post 2918041)
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)

athreyavc 10-09-2007 03:55 AM

Thank you radoulov

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

Thanks a million

Best Regards,

Athreya


All times are GMT -5. The time now is 09:26 PM.