RE: [SLUG] sh sed problem

From: Eben King (eben1@tampabay.rr.com)
Date: Tue Jan 20 2004 - 13:22:25 EST


On Tue, 20 Jan 2004, Bill Glidden wrote:

> > -----Original Message-----
> > From: slug@nks.net [mailto:slug@nks.net] On Behalf Of Backward Thinker
> > Sent: Tuesday, January 20, 2004 9:49 AM
> > To: slug@nks.net
> > Cc: slug@nks.net
> > Subject: Re: [SLUG] sh sed problem
> >
> >
> > >> here's my test.sh:
> > >>
> > >> #!/bin/sh
> > >> BLAH= echo "$1" | sed 's/.*\\//'
> > >> echo $BLAH
> > >> BLAH= ` echo "$1" | sed 's/.*\\//' `
> > >> echo $BLAH
> > >>
> > >> if I call ./test.sh 'blah\blah' I see:
> > >> blah
> > >>
> > >> sed: -e expression #1, char 7: Unterminated `s' command
> > >>
> > >>
> > >> In neither case is BLAH getting set to anything useful. The first
> > >> case is because the output is going to stdout, but in the second
> > >> case, I thought BLAH would get set? It's the same sed comand, but
> > >> with this usage I get an error? Help?
> >
> > > You need to put the expression in backticks.
> > > BLAH=`echo something`
> >
> > The second one was in backticks, but I get unterminated `s' command.

> Change to :
>
> BLAH=`echo "$1" | sed 's/.*\\\//'`
>
> My linux box is down, but that works on Solaris.

Also, include a g option in the sed command, as there might be more than
one backslash.

-- 
-eben    ebQenW1@EtaRmpTabYayU.rIr.OcoPm    home.tampabay.rr.com/hactar
   Your pretended fear lest error might step in is like the man who
   would keep all wine out of the country lest men should be drunk.
                                                 -- Oliver Cromwell

----------------------------------------------------------------------- This list is provided as an unmoderated internet service by Networked Knowledge Systems (NKS). Views and opinions expressed in messages posted are those of the author and do not necessarily reflect the official policy or position of NKS or any of its employees.



This archive was generated by hypermail 2.1.3 : Fri Aug 01 2014 - 20:26:37 EDT