Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: notesfiles Path: utzoo!linus!decvax!ittvax!dcdwest!sdcsvax!sdcrdcf!hplabs!hp-pcd!hpfcla!ajs From: ajs@hpfcla.UUCP Newsgroups: net.lang.c Subject: Re: C and AWK questions Message-ID: <40100007@hpfcla.UUCP> Date: Mon, 13-Aug-84 14:51:00 EDT Article-I.D.: hpfcla.40100007 Posted: Mon Aug 13 14:51:00 1984 Date-Received: Sat, 25-Aug-84 03:27:44 EDT References: <134@chemabs.UUCP> Organization: Hewlett-Packard - Fort Collins, CO Lines: 35 Nf-ID: #R:chemabs:-13400:hpfcla:40100007:000:876 Nf-From: hpfcla!ajs Aug 17 13:51:00 1984 > Does anyone know of a way to invoke a program from within AWK, passing it > one or more awk variables, and then trapping its output into another awk > variable? The invoking part is easy; just print to a pipe. You can print variables: print foo bar | echo I don't know of a way to trap the output from the echo, however, except perhaps in a file (which does the current awk invocation no good). > Does anyone know how to get input from multiple files simultaneously from > within an awk program? The only way I know of is ugly. Try this: sep="==sep==" # or some other pattern. { cat file1 echo $sep cat file2 } | awk ' (flag == 0) { # first file. if ($0 == "'$sep'") { flag = 1; next; } (do stuff from first file here (save data?)) next; } { # second file. (do stuff from second file here) }'