Reputation: 81
I have two unix files A and B.
A is like
100
101
102
B is like
ABC
DEF
GHI
How do I have one single consolidated like
100 ABC
101 DEF
102 GHI
like the first column joined with first column of other file.
Upvotes: 0
Views: 345
Reputation: 4325
You use paste.
NAME
paste - merge lines of files
SYNOPSIS
paste [OPTION]... [FILE]...
DESCRIPTION
Write lines consisting of the sequentially corresponding lines from each FILE, separated by TABs, to standard output. With no FILE, or when FILE is -, read standard
input.
The following command should do the trick
paste A B
Upvotes: 2
Reputation: 750
use a scripting language, like python?
>>> fina = open("a")
>>> finb = open("b")
>>> for i in fina.readlines():
... j = finb.readline()
... print (i.strip() + " " + j.strip())
...
Upvotes: 1