[SLUG] sh sed problem

From: Backward Thinker (backwardthinker@juno.com)
Date: Tue Jan 20 2004 - 08:48:28 EST


Okay, hopefully a quickie for the sed and shell script masters.

An argument to a script will be a string with an optional "\" in it. I want BLAH to be everything AFTER the "\" if present, or the whole string if no "\" is present.

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?

Thanks,
~ 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 archive was generated by hypermail 2.1.3 : Fri Aug 01 2014 - 20:25:51 EDT