Am I using old-AWK or new-AWK?

Brian Fitzgerald fitz at mml0.meche.rpi.edu
Sat Jan 5 11:52:58 AEST 1991


In article <BRISTER.91Jan3162556 at westworld.decwrl.dec.com> brister at decwrl.dec.com (James Brister) writes:
>Suppose I want to call AWK from a shell script, but I need the new version
>of AWK.  Is there a little AWK script that will tell me what version I'm
>using in a "decent" manner (i.e. doesn't just break if run under the old
>version).

If ARGC (argument count) is not predefined in your "old awk", try the
following:

#!/bin/sh
if awk 'BEGIN{ if (ARGC == 0 ) exit 0 ; exit 1 }'
then
    echo "Bad awk version" >&2
    exit 1
fi
... rest of shell script

Brian Fitzgerald



More information about the Comp.unix.shell mailing list