Sujet : Re: Splitting in shell (bash)
De : mail (at) *nospam* axel-reichert.de (Axel Reichert)
Groupes : comp.unix.shellDate : 10. Nov 2024, 09:14:45
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <87msi74ia2.fsf@axel-reichert.de>
References : 1 2
User-Agent : Gnus/5.13 (Gnus v5.13)
gazelle@shell.xmission.com (Kenny McCormack) writes:
Kenny McCormack <gazelle@shell.xmission.com> wrote:
mapfile -td ';' < <(someprocess | awk 1 ORS=)
[...]
mapfile -t < <(someprocess | sed 's/;/\n/g')
And in your original post you wrote:
There is a feature that is prominently missing from the shell language
(I am speaking primarily of bash here) - which is the ability to split
a string on a delimiter. This is a common operation in most other
text-processing oriented languages (AWK, Perl, etc).
So why bother with a shell solution and why bother with avoiding IFS,
when in the end you need to resort to AWK/sed anyway?
Do not get me wrong, I am learning a lot in this thread here, much of
the stuff is far beyond my level of expertise in shell programming, and
it would be great to have a shell-only solution for your inquiry, even
if only for "academic reasons" because, say, the solution (still to
come) may turn out to be too clumsy for daily use). I will applaud such
a result, but for the time being I would be happy if you could elaborate
somewhat more about your motivation for this exercise.
Best regards
Axel