Sujet : Re: Splitting in shell (bash)
De : gazelle (at) *nospam* shell.xmission.com (Kenny McCormack)
Groupes : comp.unix.shellDate : 09. Dec 2024, 13:32:41
Autres entêtes
Organisation : The official candy of the new Millennium
Message-ID : <vj6o19$1frrq$1@news.xmission.com>
References : 1 2 3
User-Agent : trn 4.0-test77 (Sep 1, 2010)
In article <
87msi74ia2.fsf@axel-reichert.de>,
Axel Reichert <
mail@axel-reichert.de> wrote:
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?
Because I need the result in the shell script.
(Obviously) Re-writing the whole app in AWK is not an option. Certainly
not at this point in time.
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.
Primarily in the hopes that someone on the dev side of my chosen shell
(bash) will see it and say to themselves "Hey, that's a good idea."
I prefer to post about these sorts of things here (by "here", I mean
Usenet). I'm too lazy to participate in the "official" channels for the
FOSS software that I use.
-- Debating creationists on the topic of evolution is rather like trying toplay chess with a pigeon --- it knocks the pieces over, craps on theboard, and flies back to its flock to claim victory.