[Gllug] More on that bash script

Dylan dylan at dylan.me.uk
Sat Apr 9 19:12:15 UTC 2005


On Saturday 09 Apr 2005 17:12 pm, Russell Howe wrote:
> On Sat, Apr 09, 2005 at 04:21:57PM +0100, Dylan wrote:
> > Hi All,
> >
> > having used ogginfo to extract the tags from a file to use for
> > renaming purposes, I find some of the tags contain the "/"
> > character...
> >
> > I've tried all sorts of things, but can't seem to get it just
> > right, so please - how would I change it to a "-" for example?
>
> In the same section of the bash man page, it talks about doing stuff
> like the following:
>
> ${var/foo/bar} - gives the value of var, with the first occurance (if
> any) of foo changed to bar.
>
> ${var//foo/bar} - as above, but replaces all occurances.
>

Yes indeed, played with those. 

> So I guess you want something like:
>
> artist="${tag///-}"

Unfortunately not - with and without quotes, and using three or four "/" 
the tag remains unchanged. What we had both forgotten tho was to escape 
the middle "/"!

>Note that the quotes are critically important from a security
>standpoint.

Are they, it doesn't work with them - only without:

ARTIST=${ARTIST/\//-}

gives the required result.

Dylan
-- 
"I see your Schwartz is as big as mine" 
                                  -Dark Helmet
-- 
Gllug mailing list  -  Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug




More information about the GLLUG mailing list