Ron Gemeinhardt wrote:
> Steve Long wrote:
>> Nirbheek Chauhan wrote:
>>> On Fri, Sep 26, 2008 at 2:09 PM, Steve Long
>>> <slong@...> wrote:
>>>> Nirbheek Chauhan wrote:
>>>>> $(for ACRONYM in ${LinkedIn}; do echo -en "${ACRONYM},"; done; echo
>>>>> -ne '\b')
>>>>>
>>>> Now that *is* fail ;-)
>>> Crap! I forgot, \b only works for displaying in the terminal; doesn't
>>> actually "backspace" :(
>>>
>> Eh works well enough for display (not file as you mentioned) ... <snip>
>
> Gentlemen, please...can we talk about me for a minute?
> Though entertaining, this byplay eats into my allotted fifteen minutes of
> fame. ;-)
>
LMAO.
> Besides, you really want something like:
>
Heh, you had to go there.. I think you'll fit right in ;-)
> echo "knowledge of $(unset last; for ACRONYM in ${LinkedIn[*]};
> do echo -n ${last:+,}$arg; last=$arg; done)."
>
> But I wasn't recruited to be a ebuild dev (Calchan would add, "yet") so I
> won't point that out.
>
That's good ;p as all that does is what:
(IFS=,; echo "Knowledge of: ${LinkedIn[*]}")
..does, only not as elegantly (tho I don't like the subshell) nor is it
actually correct; quite apart from the typo, it will split on any
whitespace, not array members (which can be _any_ string). If you want to
iterate over an array, use: for foo in "${array[@]}"
Another good one is: printf '%s\n' "${array[@]}"
NB: without quotes, there's no difference between ${array[@]} and
${array[*]}. They will both be treated as a string split into parameters
according to IFS (space, tab and newline by default; unset IFS only uses
space.) This is similar to: echo $foo vs: echo "$foo"
Quotes around the * form gives a single string, with each array member
separated by the first char of IFS (space by default or if unset, use IFS=
to get no separator.) Quotes around the @ form gives every member as a
separate parameter (which is what you pretty much always want, except for
display.)
> Thanks to all for the warm welcome! I promise to do my best to moderate
> the forums in the capricious, arbitrary and inscrutable--err, I mean, fair
> and balanced--manner to which we're all accustomed.
>
Glad to hear it, I've often thought the Forums should be more like Fox in
proselytising The Gentoo Way?.. *runs*
|