Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!thunder.mcrcim.mcgill.edu!snorkelwacker.mit.edu!usc!zaphod.mps.ohio-state.edu!sdd.hp.com!spool2.mu.edu!uunet!mcsun!ukc!pyrltd!root44!gwc From: gwc@root.co.uk (Geoff Clare) Newsgroups: comp.unix.questions Subject: Re: How to merge two files in awk?? Message-ID: <2583@root44.co.uk> Date: 23 Jan 91 15:18:03 GMT References: <3404@d75.UUCP> <1991Jan19.194124.2335@convex.com> <25041:Jan2017:21:1491@kramden.acf.nyu.edu> Organization: UniSoft Ltd., London, England Lines: 35 In article <1991Jan19.194124.2335@convex.com> tchrist@convex.COM (Tom Christiansen) writes: > : for example if File A has collumns a, c, e > : and File B has collumns b, d, f. I want to generate File C > : with collumns a,b,c,d,e,f. Also it would be nice to be able to > : using the arithematic feature in awk... > Someone out there may have as paste solution, but I didn't see one. In <25041:Jan2017:21:1491@kramden.acf.nyu.edu> brnstnd@kramden.acf.nyu.edu (Dan Bernstein) writes: }Is that a challenge? } #!/bin/sh } # untested, but too simple to fail in strange ways } # type X as tab } awk '{ print $1; print $2; print $3 }' < "$1" > /tmp/file1.$$ } awk '{ print $1; print $2; print $3 }' < "$2" > /tmp/file2.$$ } paste /tmp/file1.$$ /tmp/file2.$$ | ( } while read i } do } read j; read k } echo "$iX$jX$k" } done } ) } rm /tmp/file1.$$ /tmp/file2.$$ That is really gross! Try this: paste "$1" "$2" | awk '{print $1, $4, $2, $5, $3, $6}' -- Geoff Clare (Dumb American mailers: ...!uunet!root.co.uk!gwc) UniSoft Limited, London, England. Tel: +44 71 729 3773 Fax: +44 71 729 3273