[Sussex] Bash string substitution

Steve Dobson steve at dobson.org
Fri Sep 30 13:21:31 UTC 2005


Ronan

On Fri, Sep 30, 2005 at 01:55:44PM +0100, Ronan Chilvers wrote:
> Sorry to reply to my own post but just cracked it:
> 
> for FIL in "Catalogue labels Size "$1/.*; do
> 	PAT="s/A/BC/g"
> 	NEW=$(basename "$FIL" | sed "$PAT")
> 	echo $NEW
> done
> 
> I was using single rather than double quotes on my sed expression which
> is where the problem lay...

I always use signle quotes on my sed scripts.  I would have writen
your line as:
   $NEW=`basename $FIL | sed -e 's/A/BC/g'`

Steve

-- 
Anthony's Law of Force:
	Don't force it; get a larger hammer.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://mailman.lug.org.uk/pipermail/sussex/attachments/20050930/35f2a3a9/attachment.pgp 


More information about the Sussex mailing list