[Gllug] Parsing strings in a shell script

Richard Jones rich at annexia.org
Fri Sep 10 09:05:18 UTC 2004


On Thu, Sep 09, 2004 at 09:18:01PM +0100, Dylan wrote:
> dylan at scooby(1):/media/server/music/test> ogginfo "David Bowie - Blue 
> Jean.ogg" | grep ARTIST
>         ARTIST=David Bowie

It's _almost_ possible to do:

$ eval `ogginfo 01-spandau_ballet__gold.ogg | grep artist`
$ echo $artist
Various

But this fails in the general case where the values contain spaces or
shell metacharacters:

$ eval `ogginfo 01-spandau_ballet__gold.ogg | grep '='`
bash: syntax error near unexpected token `('

I can't find out the bashness to make it ignore the spaces, brackets
and so on.  Setting IFS doesn't help ...

Rich.

-- 
Richard Jones. http://www.annexia.org/ http://www.j-london.com/
Merjis Ltd. http://www.merjis.com/ - improving website return on investment
PTHRLIB is a library for writing small, efficient and fast servers in C.
HTTP, CGI, DBI, lightweight threads: http://www.annexia.org/freeware/pthrlib/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 196 bytes
Desc: Digital signature
URL: <http://mailman.lug.org.uk/pipermail/gllug/attachments/20040910/49b84f97/attachment.pgp>
-------------- next part --------------
-- 
Gllug mailing list  -  Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug


More information about the GLLUG mailing list