Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm looking for a solution for the following simple problem. I have two files, fileA and fileB. Each file contains only one word per line, and they contain exactly the same number of lines.

I would like to create a new file called fileAB, where the i-th line contains the i-th line of fileA, a Tab separator character, and then the i-th line of fileB. I know how to do it in Python or other scripting languages, but it would be nice to have a bash one-liner for that.

Is it possible to do this in bash or any other Unix shell, using the tools that are usually available on the command line (e.g., sed, awk and such)?

share|improve this question
    
Ignacio's answer is of course excellent, but it's worth mentioning that python is availbable on the command line and is in principle no less of a "one liner" than sed or paste. –  CarlF Oct 21 '10 at 18:03

2 Answers 2

up vote 10 down vote accepted

You want paste.

paste fileA fileB > fileAB
share|improve this answer
    
Yay, that's exactly what I was looking for. Thanks! –  Tamás Oct 21 '10 at 15:35

parallel --xapply -j1 -a file_1 -a file_2 echo {} > file_12

or an alternative style

parallel --xapply -k echo :::: file_1 :::: file2 > file_12

The shorter file will wrap its lines to match the length of the longer file.(if you want this behavior)

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.