From owner-freebsd-questions Fri Oct 5 13: 8:14 2001 Delivered-To: freebsd-questions@freebsd.org Received: from web9307.mail.yahoo.com (web9307.mail.yahoo.com [216.136.129.56]) by hub.freebsd.org (Postfix) with SMTP id CAE7937B405 for ; Fri, 5 Oct 2001 13:08:04 -0700 (PDT) Message-ID: <20011005200804.92243.qmail@web9307.mail.yahoo.com> Received: from [64.111.2.127] by web9307.mail.yahoo.com via HTTP; Fri, 05 Oct 2001 13:08:04 PDT Date: Fri, 5 Oct 2001 13:08:04 -0700 (PDT) From: Radhika Sambamurti Subject: Fwd: RE: Real dumb shell script/awk question To: freebsd-questions@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Another solution: --- "Lowden, James K" wrote: > From: "Lowden, James K" > To: "'Radhika Sambamurti'" > Subject: RE: Real dumb shell script/awk question > Date: Fri, 5 Oct 2001 12:27:13 -0400 > > Done, with awk. > > Create a file t: > > $ cat > t > x|y|z > A|B|C > ^D > > > if field X is equal to value Y, then print the value of > field Z > [passing an 'x' to a variable named 'X' and assuming the > first column is the > one to test]: > > $ awk -F '|' -v X=x 'match(X, $1) {print $3}' t > (output): z > > I don't know what is meant by "The user must be able to > specify X, Y, and Z > on the command line." That both the values to search for > *and* which > columns to search in are to be specified as parameters? > > --jkl > > -----Original Message----- > From: Radhika Sambamurti > [mailto:radhika_narendran@yahoo.com] > Sent: October 5, 2001 10:40 AM > To: jklowden@bernstein.com > Subject: Fwd: Real dumb shell script/awk question > > > A FREEBSD LIST QUESTION > > I think this is up your ally, O fearless database guru. > I thought of using Ksh > so i would read in the variables into var1, var2 > then grep for var1 and var2 > seems like i dont need awk. > whatdyou think? > > radhika > > > --- Kory Hamzeh wrote: > > From: "Kory Hamzeh" > > To: > > Subject: Real dumb shell script/awk question > > Date: Thu, 4 Oct 2001 17:46:53 -0700 > > > > > > I need to bang together a simple shell script to parse > a > > flat ascii > > database. The fields are variable width, but each field > > is separated by the > > "|" character. Basically, all this script needs to do > is > > to read the > > database, one line at a line, and if field X is equal > to > > value Y, then print > > the value of field Z. The user must be able to specify > X, > > Y, and Z on the > > command line. > > > > Now, for the life of me, I can't seem to figure out a > > simple way of doing > > this with a bourne shell script. I think awk can do it, > > but the man pages > > didn't help me too much with the language. I know other > > language, like perl, > > are probably better suited, but I need to customize > this > > script per the > > clients request, and it will only be needed for a > couple > > of weeks and he'll > > never need this again. > > > > Any tips on how to do this? I'm sure there is a simple > > way and I'm drawing a > > blank. > > > > Thanks, > > Kory > > > > > > To Unsubscribe: send mail to majordomo@FreeBSD.org > > with "unsubscribe freebsd-questions" in the body of the > message > > > ===== > It's all a matter of perspective. You can choose your > view by choosing where > to stand. > --Larry Wall > > __________________________________________________ > Do You Yahoo!? > NEW from Yahoo! GeoCities - quick and easy web site > hosting, just > $8.95/month. > http://geocities.yahoo.com/ps/info1 ===== It's all a matter of perspective. You can choose your view by choosing where to stand. --Larry Wall __________________________________________________ Do You Yahoo!? NEW from Yahoo! GeoCities - quick and easy web site hosting, just $8.95/month. http://geocities.yahoo.com/ps/info1 To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message