merge 3 files with awk in linux -


following problem: (similar 1 last question) tried `

 awk 'fnr==nr {a[nr]=$0;next} {print a[1]","c[1]", "$0}' file1 file2 file3  

but not work

file1:

line1 line2 line3  

and file2:

date1  

and file3:

titel1 

result should date1 merged each line of file1. result:

line1, date1, titel1 line2, date1, titel1 line3, date1, titel1 

thanks

input

[akshay@localhost tmp]$ cat f1 line1 line2 line3  [akshay@localhost tmp]$ cat f2 date1  [akshay@localhost tmp]$ cat f3 titel1 

output

[akshay@localhost tmp]$ awk 'fnr==1{i++}i<3{a[i,1]=$0;next}{print $0,a[1,1],a[2,1]}' ofs=', ' f2 f3 f1 line1, date1, titel1 line2, date1, titel1 line3, date1, titel1 

Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -