Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!yale!cmcl2!adm!news From: pspinler@att1.mankato.msus.edu (Patrick J. Spinler) Newsgroups: comp.unix.wizards Subject: sysVr3 bourne shell programming question Message-ID: <23858@adm.BRL.MIL> Date: 11 Jul 90 07:05:03 GMT Sender: news@adm.BRL.MIL Lines: 33 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@att1.Mankato.MSUS.EDU Student Programmer PSPinler@vax1.Mankato.MSUS.EDU Mankato State University PSPinler@msus1.MSUS.EDU