From owner-freebsd-questions Sun Dec 26 8:44:59 1999 Delivered-To: freebsd-questions@freebsd.org Received: from typhoon.mail.pipex.net (typhoon.mail.pipex.net [158.43.128.27]) by hub.freebsd.org (Postfix) with SMTP id 5A18A14FD9 for ; Sun, 26 Dec 1999 08:44:56 -0800 (PST) (envelope-from mark@dogma.freebsd-uk.eu.org) Received: (qmail 5259 invoked from network); 26 Dec 1999 16:44:54 -0000 Received: from userbo01.uk.uudial.com (HELO marder-1.) (62.188.145.151) by smtp.dial.pipex.com with SMTP; 26 Dec 1999 16:44:54 -0000 Received: (from mark@localhost) by marder-1. (8.9.3/8.8.8) id QAA19190; Sun, 26 Dec 1999 16:44:46 GMT (envelope-from mark) Date: Sun, 26 Dec 1999 16:44:45 +0000 From: Mark Ovens To: aunty Cc: freebsd-questions@FreeBSD.ORG Subject: Re: shell quoting problem? Message-ID: <19991226164445.F327@marder-1> References: <19991227014716.D17780@comcen.com.au> <19991226154822.C327@marder-1> <19991227032424.E17780@comcen.com.au> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 1.0pre2i In-Reply-To: <19991227032424.E17780@comcen.com.au> Organization: Total lack of Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On Mon, Dec 27, 1999 at 03:24:24AM +1100, aunty wrote: > On Sun, Dec 26, 1999 at 03:48:22PM +0000, Mark Ovens wrote: > > On Mon, Dec 27, 1999 at 01:47:16AM +1100, aunty wrote: > > > After setting some variables in a bourne shell script, I want it > > > to run a command like > > > finger @nas1 | egrep "Host|tom|dick|harry" > > > where nas1, tom, dick, and harry are expanded from variables. > > > > > > I can see _why_ things like this don't work > > > finger \@${serv} | egrep \"Host${pipes-and-names}\" > > > but can't figure out how to get all those quotes and pipes behaving. > > > > > > Is there a way to do this or must I resort to perl? > > > > > > > Not quite sure exactly what you are trying to do here, > > If you go > finger @host.domain.com > you get a list of users online (usually forbidden these days). > I'm grepping that list for particular people's names. > These names and the host name are all generated from a script. > > > but whenever I use egrep(1) I always use ``()'' thus: > > > > # finger @nas1 | egrep '(tom|dick|harry)' > > > > Does this help at all? > > Yes thanks, that's a big improvement for the right hand side. > > Now it echoes fine from the script but I get no output from the > command, probably the fault of that pesky pipe in the middle. > You mean like this: marder-1# cat > xxx #!/bin/sh finger ${1}@ukug.uk.freebsd.org | egrep "(${1}|${2})" ^D marder-1# chmod 777 xxx marder-1# ./xxx mark fred Login: mark Name: Mark Ovens Directory: /home/dogma/mark Shell: /usr/local/bin/bash Login: markg Name: Mark A. Gutierrez Directory: /home/dogma/markg Shell: /usr/local/bin/tcsh marder-1# If you're using ``${var} etc. than you need to use double quotes or the vars don't get expanded. HTH > > Merry Xmas. > > Ooooooh, yeah I forgot :-) We've just finished Boxing Day here. > Merry whatever you're celebrating! > Boxing Day evening. > > -- > > Regards, > -*Sue*- > -- "there's a long-standing bug relating to the x86 architecture that allows you to install Windows too" -Matthew D. Fuller ________________________________________________________________ FreeBSD - The Power To Serve http://www.freebsd.org My Webpage http://ukug.uk.freebsd.org/~mark/ mailto:mark@ukug.uk.freebsd.org http://www.radan.com To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message