1

I want to create a new file by copying rows of each file and pasting columnwise according to their file name orders. Here is the sample input and required output files below.

file1.txt

1234
5678
9201140

file2.txt

abcged
ghigk
lmn

required output file

out.tx

1234
abcged
5678
ghigk
9201140
lmn
  • A similar question is answered here, but with focus on shell processing. – Thor Aug 29 '14 at 9:04
4

Simply paste:

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

If you want to use awk, you can:

awk '{getline a < "file2.txt";printf "%s\n%s\n", $0, a}' file1.txt

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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