Operating System - HP-UX
1827207 Members
2553 Online
109716 Solutions
New Discussion

merge 2 single column files into one 2 column file

 
SOLVED
Go to solution
Nik
Advisor

merge 2 single column files into one 2 column file

Hi,
Anyone know how I can merge two files, each contains a 1 column list of hosts, into 1 file where the two columns are alongside each other?

thanks,
Nik
5 REPLIES 5
Andrew Lartey
Advisor
Solution

Re: merge 2 single column files into one 2 column file

paste file1 file2 > file3
melvyn burnard
Honored Contributor

Re: merge 2 single column files into one 2 column file

you may want to look at the sort command for this one.
My house is the bank's, my money the wife's, But my opinions belong to me, not HP!
waknine
New Member

Re: merge 2 single column files into one 2 column file

try the "paste" command see man pages of this command

a+
Marc
Bruce Regittko_1
Esteemed Contributor

Re: merge 2 single column files into one 2 column file

Hi,

It sounds like paste(1) is the command for you, however, you may want to take a peek at join(1), also.

--Bruce
www.stratech.com/training
Dan Lukac
New Member

Re: merge 2 single column files into one 2 column file

If the files have identical number of items you could in a script. In a script use a while command based on word count to go through the file line by line. The set up variables and set them equal to last line using the tail command and then append them to a third file.