How to pass /bin/sh parameters into
jim at ism780b.UUCP
jim at ism780b.UUCP
Wed Aug 15 14:35:44 AEST 1984
Rather than either
awk "BEGIN{id=$2;}{
printf(\"%8d %s\\n\", id++, \$0);
}" $1
or
awk "
BEGIN {id=$2;} "'
{ printf ("%8d %s\n", id++, $0); }
' $1
I much prefer
awk '
BEGIN {id='"$2"';}
{ printf ("%8d %s\n", id++, $0); }
' $1
i.e., always use single quotes to surround awk scripts,
and include Shell variables (or `` substitutions) within '" and "' .
>The 'awk' manual page talks about passing parameters via the command
>line, but I've never been able to make it work and the source for
>awk does not seem to attempt to obtain such parameters anyhow. Who knows?
That feature is only available as of System V release 2.
-- Jim Balter, INTERACTIVE Systems (ima!jim)
More information about the Comp.unix.wizards
mailing list