[Gllug] Extracting part of string in bash script

Ben Fitzgerald ben_m_f at yahoo.co.uk
Sat Apr 9 12:58:08 UTC 2005


On Sat, Apr 09, 2005 at 09:01:00AM +0100, Dylan wrote:
> On Saturday 09 Apr 2005 08:39 am, Richard Cohen wrote:
> > On Apr 9, 2005 7:29 AM, Dylan <dylan at dylan.me.uk> wrote:
> <SNIP>
> > > How can I extract the artist name and discard the rest of the line?
> >
> > Considering what bash is and isn't, it has some vaguely decent
> > text-processing built in.  In this case, the following might help:
> >
> > richardc$ foo="ARTIST=Queen"
> > richardc$ echo $foo
> > ARTIST=Queen
> > richardc$ echo ${foo#ARTIST=}
> > Queen
> > richardc$ echo ${foo#*=}
> > Queen
> 
> Nice - now to find it in the docs :)

Sure you will have found it by now, but for the record, it's
under 'Parameter Expansion' in the bash manual.

ben.

-- 
Registered Linux user number 339435
-- 
Gllug mailing list  -  Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug




More information about the GLLUG mailing list