[Gllug] Bash scripting question

Rich Walker rw at shadow.org.uk
Thu Aug 10 19:22:17 UTC 2006


Franz Timmer <ftimmer at web.de> writes:

> On Thu, 2006-08-10 at 18:52 +0100, Dylan wrote:
>> Hi All,
>> 
>> I have the following script fragment:
>> 
>> tags=( $( vorbiscomment "$1") )
>>  for tag in $(seq 0 $((${#tags[@]} - 1)))
>>   do
>>   echo ${tags[$tag]}
>>   done
>> 
>> which should extract the comments from the filename in $1 into the array 
>> $tags. So far so good. Unfortunately I find that the input is split up at 
>> spaces and line breaks, meaning that multi-word tags get distributed across 
>> more than one array element. Is there a way to get the assignment statement 
>> to break the vorbiscomment at line breaks only, or do I need to write a 
>> routine to put the broken lines back together?
>> 
>> Thanks,
>> 
>> Dylan
>
> it's very difficult to work with a bash-skript. It's better to use perl
> (or python). 

Although in this case, changing the value of IFS should help a lot.

cheers, Rich.

-- 
rich walker         |  Shadow Robot Company | rw at shadow.org.uk
technical director     251 Liverpool Road   |
need a Hand?           London  N1 1LX       | +UK 20 7700 2487
www.shadowrobot.com/hand/overview.shtml
-- 
Gllug mailing list  -  Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug




More information about the GLLUG mailing list