[Gllug] Extracting part of string in bash script

Richard Cohen vmlinuz at gmail.com
Sat Apr 9 07:39:04 UTC 2005


On Apr 9, 2005 7:29 AM, Dylan <dylan at dylan.me.uk> wrote:
> Hi All,
> 
> I'm putting together a script to rename ogg files according to the
> file's tags. Using ogginfo and grep, I can isolate the relevant tags
> like:
> 
> ARTIST=Queen
> 
> 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

> Cheers
> Dylan

Cheers
Richard
-- 
Gllug mailing list  -  Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug




More information about the GLLUG mailing list