merge two files via looping script

Hi all,

I hope you can help me.

I got a file a and a file b

File a contains
a
b
c
d
e
f
g
h

File b contains
1
2
3
4
5
6
7
8

I 'd like to display both files in another file
Result should look like this
a1
b2
c3
d4
e5
......................

Any ideas?
Thanks

paste -d '\' a b > c

Another solution, though not as simple and elegant as danmero's:

awk '{if (FILENAME=="a"){x[++i]=$0} else {print x[$0]$0}}' a b

tyler_durden

Another awk solution

awk 'NR==FNR{a[NR]=$0;next}{$0=a[FNR]$0}1' a b > c

Thanks for all the replies but still got an issue here.
Forgot to mention the most important bit.

file a

a 0001 something
a 0002 something
a 0003 something
a 0004 something

file b

b 0001 1111111111111
b 0002 2222222222222
b 0003 3333333333333
b 0004 4444444444444

File c should look like this

a 0001 something1111111111111 ( it should grep awk '{print $2}' from file a)

grep the last word if 0001 matches and add it to the current line.

Thanks
for any awk sollutions

awk 'NR==FNR{a[$2]=$NF;next}{$0=$0a[$2]}1' b a > c

Next time please post your problem at the beginning and don't try to forget important(for you) details :wink:

Sorry

paste -d"-" file1 file2 | sed 's/-//'

Thanks for the reply.

Is there an awk sollution to this problem as well?