Date: Fri, 28 Nov 2008 23:31:17 -0700 From: "Tim Judd" <tajudd@gmail.com> To: "freebsd-questions@freebsd.org" <freebsd-questions@freebsd.org> Subject: Re: shell scripting problems Message-ID: <ade45ae90811282231i15488915r773367ba75795b4c@mail.gmail.com> In-Reply-To: <20081129060801.GA41353@shepherd> References: <ade45ae90811282058k8215023r80e497fa5d857c40@mail.gmail.com> <20081129060801.GA41353@shepherd>
next in thread | previous in thread | raw e-mail | index | archive | help
I'm sure it's faulty Which is why I'm asking for help My regexes (in it's various forms) produce the output similar to: xorg-fonts-75dpi xorg-fonts xorg-fonts-100dpi ... ... ... and I'm wanting my regex to return the 2nd value, in this example, in this list. The problem is the shell is taking the end anchor $ as the start of a variable, and no matter how I escape it, it seems to never work. I'm sorry for not explaining properly. Maybe the above would help. On Fri, Nov 28, 2008 at 11:08 PM, Sahil Tandon <sahil@tandon.net> wrote: > Tim Judd <tajudd@gmail.com> wrote: > > > I've been trying for a few weeks to try to get this to work, and the > /bin/sh > > keeps snagging the command line before passing it to pkg_info > > > > I'll use a different shell if I need to, but since I got everything > except > > this one thing working, i'd rather keep it in sh > > > > In the shell script, i have a > > pkg_info -qLx "^$PKG-[0-9,._]+$" > > also tried (-X)tended regex instead of the standard rege(-x). > > > > sh keeps erroring out saying various $" isn't a valid variable name, or > > pkg_info doesn't find the anything there. And it does exist. This all > came > > around with me trying to automatically update a bunch of ports. > xorg-fonts > > is outdated, but xorg-fonts-100dpi or xorg-fonts-75dpi isn't. So the > regex > > returns multiple values (as above). I just want the first, hence the > > anchors. > > > > Any ideas on how to get sh to let pkg_info see everything? Various > escaping > > around the end $ just doesn't work. I'll keep working on it, but i'd > like > > to see how you all would suggest getting it to work. > > I am not sure what the problem is, but are you just looking for the > output of "pkg_info -qxL" on the *first* instance of xorg-fonts-*? > > % pkg_info -qL `pkg_info | grep xorg-fonts | head -1 | cut -d\ -f1` > > FWIW, your regexp also looks faulty. > > -- > Sahil Tandon <sahil@tandon.net> > _______________________________________________ > freebsd-questions@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-questions > To unsubscribe, send any mail to " > freebsd-questions-unsubscribe@freebsd.org" >
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?ade45ae90811282231i15488915r773367ba75795b4c>