Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!sdd.hp.com!caen!math.lsa.umich.edu!sharkey!wyn386!wybbs!sleepy From: sleepy@wybbs.mi.org (Mike Faber) Newsgroups: comp.unix.questions Subject: Re: How to merge two files in awk?? Message-ID: <330@wybbs.mi.org> Date: 4 Feb 91 14:16:23 GMT References: <3404@d75.UUCP> <1070@mwtech.UUCP> Reply-To: sleepy@wybbs.UUCP (Mike Faber) Organization: Consultants Connection, Jenison MI Lines: 25 In article <1070@mwtech.UUCP> you write: >In article <3404@d75.UUCP> @xlab1.uucp () writes: >> Supposing I have two files with three collumns in each. How do >> I merge the files and generate a single file with six or more >> collumns using shell script? 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... > >IMHO this is not feasable with OLD "awk" for LARGE files. [Good discussion of old/new awk and solution] Aren't we overlooking the easy solution here? paste -d"|" filea fileb | awk -F"|" ' { printf("%s %s %s %s %s %s\n", \ $1,$3,$5,$2,$4,$6) } ' >outputfile OK, it's brute force, but it's simple, easy to read, and flexible, in case the file changes. -- Michael Faber sleepy@wybbs.uucp