merge two text files using bash scripts in linux -


i have 2 text files. first 1 looks this:

a   b   c   

another file looks this:

1 2    3 4   

i want use bash scripts in linux merge these 2 files each row of first file placed next rows of second file , output looks this:

a 1 2     3 4   b 1 2   b 3 4   c 1 2   c 3 4   

any appreciated

you can use awk this:

awk 'nr==fnr{a[++n]=$0; next} {for (i in a) print $0, a[i]}' file2 file1  1 2 3 4 b 1 2 b 3 4 c 1 2 c 3 4 

reference: effective awk programming


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -