LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-13-2010, 04:57 AM   #1
pinga123
Member
 
Registered: Sep 2009
Posts: 684
Blog Entries: 2

Rep: Reputation: 36
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
 
Old 07-13-2010, 05:04 AM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,066
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
man paste




Cheers,
Tink
 
Old 07-13-2010, 05:04 AM   #3
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976
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!
 
Old 07-14-2010, 12:11 AM   #4
pinga123
Member
 
Registered: Sep 2009
Posts: 684
Blog Entries: 2

Original Poster
Rep: Reputation: 36
Quote:
Originally Posted by colucix View Post
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.
 
Old 07-14-2010, 01:10 AM   #5
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,066
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
Please mark it as such next time. I did this time around.


Cheers,
Tink
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Linux scripting documentation required morad_dba Linux - Newbie 2 06-10-2010 05:54 AM
Help Required With Shell Scripting bigbadbo Programming 4 03-20-2007 06:30 AM
Help Required With Shell Scripting bigbadbo Linux - General 3 03-19-2007 08:11 PM
teaching shell scripting: cool scripting examples? fax8 Linux - General 1 04-20-2006 05:29 AM


All times are GMT -5. The time now is 08:44 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration