sysVr3 bourne shell programming question

Patrick J. Spinler pspinler at att1.mankato.msus.edu
Wed Jul 11 17:05:03 AEST 1990


I have a shell script which calls an awk program, which, in turn,
invokes a complex command pipe in a subshell.  One of the commands I
would like to invoke from awk is a regular expression search using
egrep.  My problem is that I have been unable to pass a regular
expression containing metacharacters sucessfully into the awk script.
Would someone please come up with a better (eg, working) method ?
And, no, I don't have, nor do I intend to get, perl. :)

thanks, 
-- Pat

--- cut here ---
#
#  Get a 'who' listing, and pipe it into an awk script which will
#    1) print the listing 1 line at a time, with each line followed by
#    2) a sorted ps -f list for that user
#

epat=\\\\[0-9\\\]	# eventually supposed to be = "\[0-9\]"

who -uT | sort | ${AWK} '{
 printf ("%-8s %1s %-8s %-4s%2s%6s %-6s %s\n", $1, $2, $3, $4, $5, $6, $7, $9);
 pattern="'${epat}'" + $3;
 printf ("pattern = %s\n", pattern);
 system ("ps -fu " $1 " | sort -n +1 -2 | egrep " pattern ");
 print "";
}'

----
Patrick J. Spinler             		    PSPinler at att1.Mankato.MSUS.EDU
Student Programmer			    PSPinler at vax1.Mankato.MSUS.EDU
Mankato State University		    PSPinler at msus1.MSUS.EDU



More information about the Comp.unix.wizards mailing list