Home > database >  Merge files line after line
Merge files line after line

Time:07-14

I need your help with this query.

File-1:

What is your name?
whats your profession?
whats your interest?
Whats your favorite destination?

File-2:

My name is Combo
Executive
video games
stackoverflow forum

Need output as below:

What is your name?
My name is Combo
whats your profession?
Executive
whats your interest?
video games
Whats your favorite destination?
stackoverflow forum

I can simply use the below script, but my original file is around a thousand lines. A huge task to add echo before every questions.

#!/bin/bash
echo "What is your name?"
Combo
echo "whats your profession?"
Executive

Currently I have two notepads, one with echo and another with an answer for that. If there is a way to merge both file one by one, it will resolve my issue.

CodePudding user response:

paste can do this for you:

paste -d '\n' file1.txt file2.txt
  • Related