[Gllug] Parsing strings in a shell script

Russell Howe rhowe at wiss.co.uk
Thu Sep 9 23:06:24 UTC 2004


On Thu, Sep 09, 2004 at 09:18:01PM +0100, Dylan wrote:
>         ARTIST=David Bowie
> dylan at scooby(1):/media/server/music/test>
> 
> but I can't work out how to strip everything except the artist name 
> (leaving just David Bowie) I figured I could use:

FOO="	ARTIST=David Bowie"
BAR="${FOO/*ARTIST=}"

echo "$BAR"

No fork() required => fast

bash-specific though (maybe ksh too?)

-- 
Russell Howe       | Why be just another cog in the machine,
rhowe at siksai.co.uk | when you can be the spanner in the works?
-- 
Gllug mailing list  -  Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug




More information about the GLLUG mailing list