Shell/gawk interaction

Darin McGrew mcgrew at ichthous.Eng.Sun.COM
Fri Dec 14 10:21:33 AEST 1990


rfinch at caldwr.water.ca.gov (Ralph Finch) writes:
>I do not understand why the following bourne shell script generates an
>error in the awk program:

The whitespace in $args is not being quoted, which causes the
gawk program argument to be broken up into several arguments.
The following should work better--

	#!/bin/sh
	filename=$1 ; shift
	nargs=$#  
	args="$*"
	echo $args

	gawk '
	BEGIN {
	args="'"$args"'"
	print args
	exit 
	}' $filename

Darin McGrew			mcgrew at Eng.Sun.COM
Affiliation stated for identification purposes only.



More information about the Comp.unix.questions mailing list