Reputation: 1341
following problem: (similar to one last question) I tried `
awk 'FNR==NR {a[NR]=$0;next} {print a[1]","c[1]", "$0}' file1 file2 file3
but does not work
FILE1:
line1
line2
line3
and FILE2:
date1
and FILE3:
TITEL1
Result should be date1 merged to each line of file1. So result:
line1, date1, TITEL1
line2, date1, TITEL1
line3, date1, TITEL1
Thanks
Upvotes: 0
Views: 178
Reputation: 16997
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
Upvotes: 2