C and AWK questions
ajs at hpfcla.UUCP
ajs at hpfcla.UUCP
Tue Aug 14 04:51:00 AEST 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)
}'
More information about the Comp.lang.c
mailing list