LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Little scripting help required. (https://www.linuxquestions.org/questions/linux-newbie-8/little-scripting-help-required-819541/)

pinga123 07-13-2010 03:57 AM

Little scripting help required.
 
Hi , I need little help regarding my script.

I have a file called abc which looks below.

Rohan 12
Rakesh 23
Ajay 25

Another file looks like this (xyz).

Mumbai
Delhi
Madras

How would i add column mentioned in second file so that the file looks as below.
Rohan 12 Mumbai
Rakesh 23 Delhi

Tinkster 07-13-2010 04:04 AM

man paste




Cheers,
Tink

colucix 07-13-2010 04:04 AM

If the two files have the same number of rows, you can try the paste command, e.g. something like:
Code:

paste -d' ' abc xyz
by default paste uses TAB as delimiter but the -d option let you choose another one. Please, see man paste for details.

Edit: as Tinkster said a bunch of seconds ago! ;)

pinga123 07-13-2010 11:11 PM

Quote:

Originally Posted by colucix (Post 4031627)
If the two files have the same number of rows, you can try the paste command, e.g. something like:
Code:

paste -d' ' abc xyz
by default paste uses TAB as delimiter but the -d option let you choose another one. Please, see man paste for details.

Edit: as Tinkster said a bunch of seconds ago! ;)

This is very helpful my problem is solved.

Tinkster 07-14-2010 12:10 AM

Please mark it as such next time. I did this time around.


Cheers,
Tink


All times are GMT -5. The time now is 03:08 AM.