[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: String to array
From: |
Tapani Tarvainen |
Subject: |
Re: String to array |
Date: |
Thu, 30 Sep 2021 16:49:03 +0300 |
On Thu, Sep 30, 2021 at 01:04:08PM +0000, Leonid Isaev (ifax)
(leonid.isaev@ifax.com) wrote:
> Something like [1]? Still a for-loop though:
> -----8<-----
> array=()
> while IFS= read -r -d '' -n 1 c; do
> array+=( "$c" )
> done < <(printf "%s" "$string")
> ----->8-----
>
> [1] https://stackoverflow.com/a/40833433
Yeah, that works, but as you say it's still a loop, and neither
simpler nor faster than the substring-based ones I posted.
I may have been unclear: the solutions I posted do work, this is not a
practical problem, I'm just curious to if there's a (reasonably)
simple way to do it without a loop.
--
Tapani Tarvainen