Re: Troubles in a multiple choice
Stefan Fiedler <[email protected]> Sat, 18 Nov 2006 14:07:35 +0100
| Newsgroups | gmane.linux.distributions.rock.devel |
|---|---|
| Message-ID | <[email protected]> |
On Saturday 18 November 2006 08:43, Luca wrote:
> Hi and good morning Stefan!
>
> I tried with the examples you gave and by adding the """ after
> SUPPORTED-LOCALES and inserting it in the last line provokes a file too
> long.
Good morning!
Did you also change SUPPORTED-LOCALES to SUPPORTED_LOCALES ? Remember the
former is not a valid variable name in bash and will cause an error when
evaluating SUPPORTED like this:
. SUPPORTED
> I tried the other option and it effectively displays the entries in
> bash, but there are even the double identifications (I added a | cut -d/
> -f1,2 after done):
> it_CH.UTF-8/UTF-8 it_CH.UTF-8
> it_CH/ISO-8859-1 it_CH
> it_IT.UTF-8/UTF-8 it_IT.UTF-8
> it_IT/ISO-8859-1 it_IT
> it_IT@euro/ISO-8859-15 it_IT@euro
>
> In this way (just tried) when choosing the locales it saves, example as
> "it_IT.UTF-8.UTF-8" which obviously is not recognized.
> Obvious question, how do I manage now to remove the double "/<code>"
> from the first $x?
> (The first part should look exactly as the second, so it should looks
> like it_IT.UTF-8 it_IT.UTF-8)
>
> Thanks for efforts, patience, etc...
>
> Luca
As always, there are several ways to do this. Try the following:
grep -A9999 "SUPPORTED-LOCALES" SUPPORTED | \
while read -r x y ; do echo ${x%%/*} ${x%%/*} ; done
${x%%pattern} evaluates to x, with the longest possible pattern removed from
the end.
You could also use, with the same result:
grep -A9999 "SUPPORTED-LOCALES" SUPPORTED | \
cut -f1 -d/ | while read -r x y ; do echo $x $x ; done
Tip: I usually test such code on the command line before I use it in ROCK
scripts. That way debugging is much easier :)
With best regards,
Stefan Fiedler
P.S: I'll be AFK for this weekend and might not be able to answer questions
until Monday.