Re: [SLUG] sh sed problem

From: Daniel MacLaren (daniel-slug@creag.org)
Date: Tue Jan 20 2004 - 10:42:08 EST


Here is a script using sed and cut. I think cut is easier to read.

#!/bin/sh
BLAH=`echo "$1" | sed 's/.*[\]//'`
echo "sed: $BLAH"
BLAH=`echo "$1" | cut -d '\' -f 2`
echo "cut: $BLAH"

-Daniel

On Tue, 20 Jan 2004, Backward Thinker wrote:

>
> >> 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.
>
> ~ Daniel
>
> ________________________________________________________________
> The best thing to hit the internet in years - Juno SpeedBand!
> Surf the web up to FIVE TIMES FASTER!
> Only $14.95/ month - visit www.juno.com to sign up today!
> -----------------------------------------------------------------------
> 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 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:27 EDT