Date: Sun, 26 Dec 1999 16:44:45 +0000 From: Mark Ovens <mark@ukug.uk.freebsd.org> To: aunty <aunty@comcen.com.au> Cc: freebsd-questions@FreeBSD.ORG Subject: Re: shell quoting problem? Message-ID: <19991226164445.F327@marder-1> In-Reply-To: <19991227032424.E17780@comcen.com.au> References: <19991227014716.D17780@comcen.com.au> <19991226154822.C327@marder-1> <19991227032424.E17780@comcen.com.au>
next in thread | previous in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?19991226164445.F327>