[net.unix-wizards] How to pass /bin/sh parameters into

jim@ism780b.UUCP (08/15/84)

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)