Rocksolid Light

News from da outaworlds

mail  files  register  groups  login

Message-ID:  

Your aim is high and to the right.


comp / comp.unix.shell / Re: Numerically sorted arguments (in shell)

SubjectAuthor
* Numerically sorted arguments (in shell)Janis Papanagnou
+* Re: Numerically sorted arguments (in shell)Axel Reichert
|`- Re: Numerically sorted arguments (in shell)Janis Papanagnou
+* Re: Numerically sorted arguments (in shell)Lawrence D'Oliveiro
|`* Re: Numerically sorted arguments (in shell)Janis Papanagnou
| +* Re: Numerically sorted arguments (in shell)Lawrence D'Oliveiro
| |`* Re: Numerically sorted arguments (in shell)Janis Papanagnou
| | +* Re: Numerically sorted arguments (in shell)Helmut Waitzmann
| | |+- Re: Numerically sorted arguments (in shell)Janis Papanagnou
| | |`* Re: Numerically sorted arguments (in shell)Geoff Clare
| | | `- Re: Numerically sorted arguments (in shell)Helmut Waitzmann
| | `* Re: Numerically sorted arguments (in shell)Lawrence D'Oliveiro
| |  `* Re: Numerically sorted arguments (in shell)Janis Papanagnou
| |   `* Re: Numerically sorted arguments (in shell)Lawrence D'Oliveiro
| |    `* Re: Numerically sorted arguments (in shell)Janis Papanagnou
| |     `* Re: Numerically sorted arguments (in shell)Lawrence D'Oliveiro
| |      +- Re: Numerically sorted arguments (in shell)Kenny McCormack
| |      +- Re: Numerically sorted arguments (in shell)Janis Papanagnou
| |      `- Re: Numerically sorted arguments (in shell)Kaz Kylheku
| `* Re: Numerically sorted arguments (in shell)Eric Pozharski
|  `* Re: Numerically sorted arguments (in shell)Janis Papanagnou
|   `* Re: Numerically sorted arguments (in shell)Eric Pozharski
|    `- Re: Numerically sorted arguments (in shell)Janis Papanagnou
+* Re: Numerically sorted arguments (in shell)Chris Elvidge
|`* Re: Numerically sorted arguments (in shell)Janis Papanagnou
| `* Re: Numerically sorted arguments (in shell)Chris Elvidge
|  `* Re: Numerically sorted arguments (in shell)Janis Papanagnou
|   `- Re: Numerically sorted arguments (in shell)Janis Papanagnou
`* Re: Numerically sorted arguments (in shell)Janis Papanagnou
 `* Re: Numerically sorted arguments (in shell)Chris Elvidge
  `* Re: Numerically sorted arguments (in shell)Janis Papanagnou
   `* Re: Numerically sorted arguments (in shell)Chris Elvidge
    +* Re: Numerically sorted arguments (in shell)vallor
    |+- Re: Numerically sorted arguments (in shell)Janis Papanagnou
    |+* Re: Numerically sorted arguments (in shell)Janis Papanagnou
    ||`* Re: Numerically sorted arguments (in shell)vallor
    || `* Re: Numerically sorted arguments (in shell)Lawrence D'Oliveiro
    ||  `* Re: Numerically sorted arguments (in shell)vallor
    ||   `* Re: Numerically sorted arguments (in shell)Lawrence D'Oliveiro
    ||    `- Re: Numerically sorted arguments (in shell)Kenny McCormack
    |`* Re: Numerically sorted arguments (in shell)Chris Elvidge
    | `* Is 'ls -v' the Final Solution? (Was: Numerically sorted arguments (in shell))Kenny McCormack
    |  `- Re: Is 'ls -v' the Final Solution? (Was: Numerically sorted arguments (in shell)Janis Papanagnou
    `* Re: Numerically sorted arguments (in shell)Janis Papanagnou
     `* Re: Numerically sorted arguments (in shell)Chris Elvidge
      `- Re: Numerically sorted arguments (in shell)Janis Papanagnou

Pages:12
Subject: Numerically sorted arguments (in shell)
From: Janis Papanagnou
Newsgroups: comp.unix.shell
Organization: A noiseless patient Spider
Date: Fri, 14 Jun 2024 07:31 UTC
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: janis_papanagnou+ng@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell
Subject: Numerically sorted arguments (in shell)
Date: Fri, 14 Jun 2024 09:31:18 +0200
Organization: A noiseless patient Spider
Lines: 42
Message-ID: <v4grk8$2pp51$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 14 Jun 2024 09:31:20 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="8b24bab10403226cd861d487505b4977";
logging-data="2942113"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19KOZHT6ZlEEMsuBXKlh1FS"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:N8cfVRXz75EEqoeYmw1QXd45X/0=
X-Enigmail-Draft-Status: N1110
X-Mozilla-News-Host: news://news.eternal-september.org:119
View all headers

I'm using ksh here...

I can set the shell parameters in numerical order

$ set {1..100}

then sort them _lexicographically_

$ set -s

Or do both in one

$ set -s {1..100}

I haven't found anything to sort them _numerically_ in shell.

What I'm trying to do is iterating over files, say,
P1.HTM P10.HTM P11.HTM P2.HTM P3.HTM P4.HTM P5.HTM P6.HTM P7.HTM
P8.HTM P9.HTM
in numerical order.

Setting the files as shell arguments with P*.HTM will also produce
lexicographical order.

The preceding files are just samples. It should work also if the
numbers are non-consecutive (say, 2, 10, 10000, 3333333) so that
iterating using a for-loop and building the list is not an option.

(Ideally I'd also like to handle names with two numbers "A35P56.txt"
and irregular string components (lowercase, say, "page310ch1.txt"),
but that's just a nice-to-have. - I might make use of 'sort'?)

But the primary question is; how to organize/iterate the arguments
*numerically* _in shell_? (If that's possible in some simple way.)

N.B.: I prefer not to use external commands like 'sort' because of
the negative side effects and bulky code to handle newlines and
blanks in filenames, and messing around with quotes.

Janis

Subject: Re: Numerically sorted arguments (in shell)
From: Axel Reichert
Newsgroups: comp.unix.shell
Organization: A noiseless patient Spider
Date: Sat, 15 Jun 2024 13:56 UTC
References: 1
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: mail@axel-reichert.de (Axel Reichert)
Newsgroups: comp.unix.shell
Subject: Re: Numerically sorted arguments (in shell)
Date: Sat, 15 Jun 2024 15:56:22 +0200
Organization: A noiseless patient Spider
Lines: 25
Message-ID: <8734peia2h.fsf@axel-reichert.de>
References: <v4grk8$2pp51$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Date: Sat, 15 Jun 2024 15:56:23 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="ecc537ebfc5213417124a7d49f80461d";
logging-data="3672679"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/oZMmNqosweN2QgTyZY1hxWzAylY7UY+E="
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux)
Cancel-Lock: sha1:7aEtvUHmgl6LExf9V9W8oGCWe9k=
sha1:cvX7g9FgEASn/BHV+53qxJVd7aE=
View all headers

Janis Papanagnou <janis_papanagnou+ng@hotmail.com> writes:

> What I'm trying to do is iterating over files, say,
> P1.HTM P10.HTM P11.HTM P2.HTM P3.HTM P4.HTM P5.HTM P6.HTM P7.HTM
> P8.HTM P9.HTM
> in numerical order.

Could you employ printf to add leading zeros, sort lexicogpaphically and
then remove the zeros?

> (Ideally I'd also like to handle names with two numbers "A35P56.txt"
> and irregular string components (lowercase, say, "page310ch1.txt"),
> but that's just a nice-to-have. - I might make use of 'sort'?)

You did not yet mention what your final goal is with the numerically
sorted list.

In case this is in the end a renaming task, for this level of complexity
I would use the "wdired" mode of Emacs ("write directory edits") and use
regexes for search and replace. Or some other "multi-rename" tools from
the command line.

Best regards

Axel

Subject: Re: Numerically sorted arguments (in shell)
From: Janis Papanagnou
Newsgroups: comp.unix.shell
Organization: A noiseless patient Spider
Date: Sat, 15 Jun 2024 14:43 UTC
References: 1 2
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: janis_papanagnou+ng@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell
Subject: Re: Numerically sorted arguments (in shell)
Date: Sat, 15 Jun 2024 16:43:50 +0200
Organization: A noiseless patient Spider
Lines: 78
Message-ID: <v4k9b8$3go8u$1@dont-email.me>
References: <v4grk8$2pp51$1@dont-email.me> <8734peia2h.fsf@axel-reichert.de>
MIME-Version: 1.0
Content-Type: text/plain; charset=windows-1252
Content-Transfer-Encoding: 7bit
Injection-Date: Sat, 15 Jun 2024 16:43:52 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="2d144072adb72099b19eaf0948d9bf4f";
logging-data="3694878"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18a460rga2L6fMWhrr1fShb"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:sVLDqqA0fZPWiuG6BKqIyonpwt8=
X-Enigmail-Draft-Status: N1110
In-Reply-To: <8734peia2h.fsf@axel-reichert.de>
View all headers

On 15.06.2024 15:56, Axel Reichert wrote:
> Janis Papanagnou <janis_papanagnou+ng@hotmail.com> writes:
>
>> What I'm trying to do is iterating over files, say,
>> P1.HTM P10.HTM P11.HTM P2.HTM P3.HTM P4.HTM P5.HTM P6.HTM P7.HTM
>> P8.HTM P9.HTM
>> in numerical order.
>
> Could you employ printf to add leading zeros, sort lexicogpaphically and
> then remove the zeros?

Something like this (not using printf but a more elementary method) is
actually what I'm currently doing. (It's not really complex but quite
some data fiddling I wanted to avoid. I have that in a script and it's
not a general solution but handles just simple cases like the sample
data above, which is 95% of my usages so it's okay for that but not
really satisfying for other or more general cases.)

To get the original name back I think I'd have to store the original
names along with the new names. (Which is something I've not yet done.)

>
>> (Ideally I'd also like to handle names with two numbers "A35P56.txt"
>> and irregular string components (lowercase, say, "page310ch1.txt"),
>> but that's just a nice-to-have. - I might make use of 'sort'?)
>
> You did not yet mention what your final goal is with the numerically
> sorted list.

The original application was that I simply wanted to sequentially skim
through a number of files.[*] In the past (where possible) I've just
renamed the files to let them have numbers of equal length (as noted
above). But the general task I envision is that I don't want to change
any name of data files but just be able to iterate over these files,
or list them numerically sorted (and without the known issues of \n
and blank handling).

I thought that a contemporary shell would probably support that but I
was astonished that (at least in ksh) it wasn't supported (as far as
I saw).[**]

>
> In case this is in the end a renaming task, for this level of complexity
> I would use the "wdired" mode of Emacs ("write directory edits") and use
> regexes for search and replace. Or some other "multi-rename" tools from
> the command line.

I've my own script to adjust numbers in files. But as said, I'd rather
want to iterate or sort, like the lexicographic ordering in ksh

set -s page*.gif

(which in that example is anyway the default for wildcard patterns)
something similar for numeric argument setting (or pattern expansion)

set --numerical page*.gif

To use that features more widely it would be nice if the wild-card
expansion could be controlled, say by

set -o numerical

Well, maybe that all makes no sense and should be tackled differently?
But it's how it appears to me at the moment. (Feel free to enlighten
me. :-)

Janis

[*] I occasionally have this task; the last time was when I wanted to
read old typewriter documents that had been scanned page-wise as GIF
files.

[**] Yet I haven't checked Zsh; that shell supports some non-standard
modifiers in certain zsh-specific constructs, so it might possible it
has support for this requirement as well. (But Zsh is not the shell
I'm using so I'm primarily seeking for a Ksh solution or POSIX shell
workaround.)

Subject: Re: Numerically sorted arguments (in shell)
From: Lawrence D'Oliv
Newsgroups: comp.unix.shell
Organization: A noiseless patient Spider
Date: Sat, 15 Jun 2024 22:49 UTC
References: 1
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ldo@nz.invalid (Lawrence D'Oliveiro)
Newsgroups: comp.unix.shell
Subject: Re: Numerically sorted arguments (in shell)
Date: Sat, 15 Jun 2024 22:49:05 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 9
Message-ID: <v4l5p1$3lqic$10@dont-email.me>
References: <v4grk8$2pp51$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Sun, 16 Jun 2024 00:49:05 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="bd45dcd0b5a25b060647b4de82583354";
logging-data="3861068"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+d0bdnKzAklweYLsb99pLo"
User-Agent: Pan/0.158 (Avdiivka; )
Cancel-Lock: sha1:pNOEDGu75KUQnNG9AOouLO8nFMk=
View all headers

On Fri, 14 Jun 2024 09:31:18 +0200, Janis Papanagnou wrote:

> I'm using ksh here...

At some point, you have to accept that trying to do everything in a shell
language is not the best way to go, and that it is time to switch to a
“real” programming language.

For example, Perl or Python could do this much more easily.

Subject: Re: Numerically sorted arguments (in shell)
From: Janis Papanagnou
Newsgroups: comp.unix.shell
Organization: A noiseless patient Spider
Date: Sun, 16 Jun 2024 03:11 UTC
References: 1 2
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: janis_papanagnou+ng@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell
Subject: Re: Numerically sorted arguments (in shell)
Date: Sun, 16 Jun 2024 05:11:29 +0200
Organization: A noiseless patient Spider
Lines: 30
Message-ID: <v4ll54$3sd11$1@dont-email.me>
References: <v4grk8$2pp51$1@dont-email.me> <v4l5p1$3lqic$10@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Injection-Date: Sun, 16 Jun 2024 05:11:32 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="14bb39f07e17302d959adafc07d464c7";
logging-data="4076577"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/sjHncVRffPAKC/qAOm/y7"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:LIkyY0YO57xQa17cYajIXod1x9U=
X-Enigmail-Draft-Status: N1110
In-Reply-To: <v4l5p1$3lqic$10@dont-email.me>
View all headers

On 16.06.2024 00:49, Lawrence D'Oliveiro wrote:
> On Fri, 14 Jun 2024 09:31:18 +0200, Janis Papanagnou wrote:
>
>> I'm using ksh here...
>
> At some point, you have to accept that trying to do everything in a shell
> language is not the best way to go, and that it is time to switch to a
> “real” programming language.

What argument are you trying to make up? What makes you think
I'm doing "everything in a shell"?

(My approach is to take the appropriate tools and language from
the set of (a dozen, or so) "real" languages I know, plus from
the set of a handful of scripting languages that I know.)

> For example, Perl or Python could do this much more easily.

I don't know of this feature in Perl or Python; please provide
some hint if there is a feature like the one I need. Some code
samples for demonstration of your point are also welcome.

(Only in case you missed it; I'm not [primarily] looking for a
program; for the described task I'm fine with what I have done.
Rather I'm looking for an inherent feature that supports what I
described elsethread. And I like to have this feature in shell
since a shell is my standard interface to my Unix system. HTH.)

Janis

Subject: Re: Numerically sorted arguments (in shell)
From: Lawrence D'Oliv
Newsgroups: comp.unix.shell
Organization: A noiseless patient Spider
Date: Sun, 16 Jun 2024 04:56 UTC
References: 1 2 3
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ldo@nz.invalid (Lawrence D'Oliveiro)
Newsgroups: comp.unix.shell
Subject: Re: Numerically sorted arguments (in shell)
Date: Sun, 16 Jun 2024 04:56:39 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 36
Message-ID: <v4lra6$3t7b2$2@dont-email.me>
References: <v4grk8$2pp51$1@dont-email.me> <v4l5p1$3lqic$10@dont-email.me>
<v4ll54$3sd11$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Sun, 16 Jun 2024 06:56:39 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="226f25248701f9e2b898433032a62efe";
logging-data="4103522"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18F2DZecv8TYLmWOosmBzNw"
User-Agent: Pan/0.158 (Avdiivka; )
Cancel-Lock: sha1:/r/BxQH7YukmqqmhBkAK5j+tq64=
View all headers

On Sun, 16 Jun 2024 05:11:29 +0200, Janis Papanagnou wrote:

> I don't know of this feature in Perl or Python; please provide some hint
> if there is a feature like the one I need. Some code samples for
> demonstration of your point are also welcome.

Python solution:

import re

items = \
[
"P1.HTM", "P10.HTM", "P11.HTM", "P2.HTM", "P3.HTM",
"P4.HTM", "P5.HTM", "P6.HTM", "P7.HTM", "P8.HTM", "P9.HTM",
]

print(items)

print \
(
sorted
(
items,
key = lambda f :
tuple
(
(lambda : p, lambda : int(p))[i % 2 != 0]()
for i, p in enumerate(re.split("([0-9]+)", f))
)
)
)

output:

['P1.HTM', 'P10.HTM', 'P11.HTM', 'P2.HTM', 'P3.HTM', 'P4.HTM', 'P5.HTM', 'P6.HTM', 'P7.HTM', 'P8.HTM', 'P9.HTM']
['P1.HTM', 'P2.HTM', 'P3.HTM', 'P4.HTM', 'P5.HTM', 'P6.HTM', 'P7.HTM', 'P8.HTM', 'P9.HTM', 'P10.HTM', 'P11.HTM']

Subject: Re: Numerically sorted arguments (in shell)
From: Janis Papanagnou
Newsgroups: comp.unix.shell
Organization: A noiseless patient Spider
Date: Sun, 16 Jun 2024 09:48 UTC
References: 1 2 3 4
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: janis_papanagnou+ng@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell
Subject: Re: Numerically sorted arguments (in shell)
Date: Sun, 16 Jun 2024 11:48:25 +0200
Organization: A noiseless patient Spider
Lines: 64
Message-ID: <v4mcda$99f$1@dont-email.me>
References: <v4grk8$2pp51$1@dont-email.me> <v4l5p1$3lqic$10@dont-email.me>
<v4ll54$3sd11$1@dont-email.me> <v4lra6$3t7b2$2@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
Injection-Date: Sun, 16 Jun 2024 11:48:27 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="567efb17d94aca7729125b64ceeb67a7";
logging-data="9519"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19zrxlMHKl3wMzW+1NqrAIT"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:FGfcXVq6mfC3aFolY6KhHqWDRoA=
X-Enigmail-Draft-Status: N1110
In-Reply-To: <v4lra6$3t7b2$2@dont-email.me>
View all headers

On 16.06.2024 06:56, Lawrence D'Oliveiro wrote:
> On Sun, 16 Jun 2024 05:11:29 +0200, Janis Papanagnou wrote:
>
>> I don't know of this feature in Perl or Python; please provide some hint
>> if there is a feature like the one I need. Some code samples for
>> demonstration of your point are also welcome.
>
> Python solution:
>
> import re
>
> items = \
> [
> "P1.HTM", "P10.HTM", "P11.HTM", "P2.HTM", "P3.HTM",
> "P4.HTM", "P5.HTM", "P6.HTM", "P7.HTM", "P8.HTM", "P9.HTM",
> ]
>
> print(items)
>
> print \
> (
> sorted
> (
> items,
> key = lambda f :
> tuple
> (
> (lambda : p, lambda : int(p))[i % 2 != 0]()
> for i, p in enumerate(re.split("([0-9]+)", f))
> )
> )
> )
>
> output:
>
> ['P1.HTM', 'P10.HTM', 'P11.HTM', 'P2.HTM', 'P3.HTM', 'P4.HTM', 'P5.HTM', 'P6.HTM', 'P7.HTM', 'P8.HTM', 'P9.HTM']
> ['P1.HTM', 'P2.HTM', 'P3.HTM', 'P4.HTM', 'P5.HTM', 'P6.HTM', 'P7.HTM', 'P8.HTM', 'P9.HTM', 'P10.HTM', 'P11.HTM']
>

Thanks. Though I'm not familiar with Python to understand that code;
it's too far from any language I've been using.

The (for me) interesting question, though, is; how does it solve the
task I had been addressing? - For convenience I reiterate one main
application...

I want from my shell command line interface call a viewer (or any
other application) with a list of files. If in shell I do, e.g.,

viewer P*.HTM

the list gets sorted lexicographically. How would the main function
look like that I could embed in my call to make a numerically sorted
list. Say, something like, for example,

viewer $( p_sort P*.HTM )

where p_sort would be the Python code. - Note: this is no appropriate
solution since it would anyway not work correctly for file names with
embedded blanks and newlines. I just want to get a closer understanding
how you think this would be usable in shell (or from shell). Thanks.

Janis

Subject: Re: Numerically sorted arguments (in shell)
From: Helmut Waitzmann
Newsgroups: comp.unix.shell
Organization: A noiseless patient Spider
Date: Sun, 16 Jun 2024 19:52 UTC
References: 1 2 3 4 5
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: nn.throttle@xoxy.net (Helmut Waitzmann)
Newsgroups: comp.unix.shell
Subject: Re: Numerically sorted arguments (in shell)
Date: Sun, 16 Jun 2024 21:52:58 +0200
Organization: A noiseless patient Spider
Lines: 33
Sender: Helmut Waitzmann <12f7e638@mail.de>
Message-ID: <83sexcll5x.fsf@helmutwaitzmann.news.arcor.de>
References: <v4grk8$2pp51$1@dont-email.me> <v4l5p1$3lqic$10@dont-email.me>
<v4ll54$3sd11$1@dont-email.me> <v4lra6$3t7b2$2@dont-email.me>
<v4mcda$99f$1@dont-email.me>
Reply-To: Helmut Waitzmann Anti-Spam-Ticket.b.qc3c <oe.throttle@xoxy.net>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: quoted-printable
Injection-Date: Sun, 16 Jun 2024 22:02:19 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="f5f358d69d9ad6ef9798d2a98513821d";
logging-data="233980"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18WcpffdVqTUlTwcIgzMZHGMkMvBg0cSIM="
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux)
Cancel-Lock: sha1:X+XyUUgbZUQOD7oc9pDYvuxwV/s=
sha1:yzoeVU5SUL13GETBnLZqX+ZqjzY=
Mail-Reply-To: Helmut Waitzmann Anti-Spam-Ticket.b.qc3c <oe.throttle@xoxy.net>
Mail-Copies-To: nobody
View all headers

Janis Papanagnou <janis_papanagnou+ng@hotmail.com>:
> How would the main function look like that I could embed in my
> call to make a numerically sorted list. Say, something like, for
> example,
>
>
> viewer $( p_sort P*.HTM )
>
> where p_sort would be the Python code. - Note: this is no
> appropriate solution since it would anyway not work correctly
> for file names with embedded blanks and newlines. I just want to
> get a closer understanding how you think this would be usable in
> shell (or from shell). Thanks.
>

If ‘p_sort’ is designed to output the sorted file names separated
by an ASCII NUL character rather than a newline then, using the
GNU version of ‘xargs’, one can feed that output into ‘xargs’:

{
p_sort P*.HTM 3<&- |
xargs --null --no-run-if-empty -- sh -c \
'exec 0<&3 3<&- "$@"' sh \
viewer
} 3<&0

This will avoid the problems with funny characters (including
blanks and linefeeds) in filenames processed by the shell.

Subject: Re: Numerically sorted arguments (in shell)
From: Eric Pozharski
Newsgroups: comp.unix.shell
Organization: A noiseless patient Spider
Date: Sun, 16 Jun 2024 18:00 UTC
References: 1 2 3
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: apple.universe@posteo.net (Eric Pozharski)
Newsgroups: comp.unix.shell
Subject: Re: Numerically sorted arguments (in shell)
Date: Sun, 16 Jun 2024 18:00:11 +0000
Organization: A noiseless patient Spider
Lines: 42
Message-ID: <slrnv6ua1b.qfh.apple.universe@freight.zombinet>
References: <v4grk8$2pp51$1@dont-email.me> <v4l5p1$3lqic$10@dont-email.me>
<v4ll54$3sd11$1@dont-email.me>
Injection-Date: Mon, 17 Jun 2024 03:33:14 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="823c10b5e3c15c56bf2e9ffce1de0af2";
logging-data="348460"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19qKkG8GYcYV7M9MBx6WJSU"
User-Agent: slrn/1.0.3 (Linux)
Cancel-Lock: sha1:syS5IVA99dB7vwCunSgVFrZN7Uc=
View all headers

with <v4ll54$3sd11$1@dont-email.me> Janis Papanagnou wrote:
> On 16.06.2024 00:49, Lawrence D'Oliveiro wrote:
>> On Fri, 14 Jun 2024 09:31:18 +0200, Janis Papanagnou wrote:

>>> I'm using ksh here...
*SKIP* [ 8 lines 2 levels deep] # borderly ad hominem
> (My approach is to take the appropriate tools and language from the
> set of (a dozen, or so) "real" languages I know, plus from the set of
> a handful of scripting languages that I know.)

(Disclaimer: I'm ksh-ignorant) Speaking of features.

{14439:44} [0:0]% print -cC6 *
bar-20.baz bar-3.baz foo-10.bar foo-23.bar foo-5.bar
bar-21.baz bar-6.baz foo-13.bar foo-29.bar foo-6.bar
bar-24.baz bar-8.baz foo-1.bar foo-3.bar foo-7.bar
bar-26.baz foo-0.bar foo-22.bar foo-4.bar foo-8.bar
{14445:45} [0:0]% print -cC6 *(n)
bar-3.baz bar-21.baz foo-1.bar foo-6.bar foo-13.bar
bar-6.baz bar-24.baz foo-3.bar foo-7.bar foo-22.bar
bar-8.baz bar-26.baz foo-4.bar foo-8.bar foo-23.bar
bar-20.baz foo-0.bar foo-5.bar foo-10.bar foo-29.bar

That nymph between weapon and tool is 'glob qualifier' (acts at
'filename generation' phase). But! It's zsh. That being said, as a
result of cross-pollination, something similar might be in ksh too. I
can't say where to dig through ksh-documentation.

>> For example, Perl or Python could do this much more easily.
> I don't know of this feature in Perl or Python; please provide some
> hint if there is a feature like the one I need. Some code samples for
> demonstration of your point are also welcome.

Well, here's a hint:

Rule#34: If you can imagine sex, there's a module for this.

*CUT* [ 10 lines 1 level deep]

--
Torvalds' goal for Linux is very simple: World Domination
Stallman's goal for GNU is even simpler: Freedom

Subject: Re: Numerically sorted arguments (in shell)
From: Lawrence D'Oliv
Newsgroups: comp.unix.shell
Organization: A noiseless patient Spider
Date: Mon, 17 Jun 2024 05:42 UTC
References: 1 2 3 4 5
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ldo@nz.invalid (Lawrence D'Oliveiro)
Newsgroups: comp.unix.shell
Subject: Re: Numerically sorted arguments (in shell)
Date: Mon, 17 Jun 2024 05:42:57 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 6
Message-ID: <v4oid0$gnmb$1@dont-email.me>
References: <v4grk8$2pp51$1@dont-email.me> <v4l5p1$3lqic$10@dont-email.me>
<v4ll54$3sd11$1@dont-email.me> <v4lra6$3t7b2$2@dont-email.me>
<v4mcda$99f$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Mon, 17 Jun 2024 07:42:57 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="ff2e1389104c18fa1ab521b7e2f13122";
logging-data="548555"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19HD3JJ0iqH6eppbeHUmJ/b"
User-Agent: Pan/0.158 (Avdiivka; )
Cancel-Lock: sha1:Bcvz5Db52iwHnobGrIhlGS5L/Qw=
View all headers

On Sun, 16 Jun 2024 11:48:25 +0200, Janis Papanagnou wrote:

> How would the main function look like that I could embed in my call to
> make a numerically sorted list.

That’s what the code I posted does.

Subject: Re: Numerically sorted arguments (in shell)
From: Janis Papanagnou
Newsgroups: comp.unix.shell
Organization: A noiseless patient Spider
Date: Mon, 17 Jun 2024 06:21 UTC
References: 1 2 3 4
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: janis_papanagnou+ng@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell
Subject: Re: Numerically sorted arguments (in shell)
Date: Mon, 17 Jun 2024 08:21:55 +0200
Organization: A noiseless patient Spider
Lines: 30
Message-ID: <v4okm3$h4cs$1@dont-email.me>
References: <v4grk8$2pp51$1@dont-email.me> <v4l5p1$3lqic$10@dont-email.me>
<v4ll54$3sd11$1@dont-email.me>
<slrnv6ua1b.qfh.apple.universe@freight.zombinet>
MIME-Version: 1.0
Content-Type: text/plain; charset=windows-1252
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 17 Jun 2024 08:21:58 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="d070642afdec4e1c027704024e3cba98";
logging-data="561564"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18p2Ig+pVy64fd1waZAtUTn"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:zZw/yOk0pokOVF3kF4jggd2qmK4=
X-Enigmail-Draft-Status: N1110
In-Reply-To: <slrnv6ua1b.qfh.apple.universe@freight.zombinet>
View all headers

On 16.06.2024 20:00, Eric Pozharski wrote:
> with <v4ll54$3sd11$1@dont-email.me> Janis Papanagnou wrote:
>> [sorting file names numerically]
>
> (Disclaimer: I'm ksh-ignorant) Speaking of features.
>
> {14439:44} [0:0]% print -cC6 *
> bar-20.baz bar-3.baz foo-10.bar foo-23.bar foo-5.bar
> bar-21.baz bar-6.baz foo-13.bar foo-29.bar foo-6.bar
> bar-24.baz bar-8.baz foo-1.bar foo-3.bar foo-7.bar
> bar-26.baz foo-0.bar foo-22.bar foo-4.bar foo-8.bar
> {14445:45} [0:0]% print -cC6 *(n)
> bar-3.baz bar-21.baz foo-1.bar foo-6.bar foo-13.bar
> bar-6.baz bar-24.baz foo-3.bar foo-7.bar foo-22.bar
> bar-8.baz bar-26.baz foo-4.bar foo-8.bar foo-23.bar
> bar-20.baz foo-0.bar foo-5.bar foo-10.bar foo-29.bar
>
> That nymph between weapon and tool is 'glob qualifier' (acts at
> 'filename generation' phase). But! It's zsh.

Yeah, I was positive that Zsh supports such a qualifier.

> That being said, as a
> result of cross-pollination, something similar might be in ksh too. I
> can't say where to dig through ksh-documentation.

Well, I don't know of any in Ksh. (That's my problem.)

Janis

Subject: Re: Numerically sorted arguments (in shell)
From: Janis Papanagnou
Newsgroups: comp.unix.shell
Organization: A noiseless patient Spider
Date: Mon, 17 Jun 2024 06:30 UTC
References: 1 2 3 4 5 6
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: janis_papanagnou+ng@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell
Subject: Re: Numerically sorted arguments (in shell)
Date: Mon, 17 Jun 2024 08:30:54 +0200
Organization: A noiseless patient Spider
Lines: 36
Message-ID: <v4ol6v$h77r$1@dont-email.me>
References: <v4grk8$2pp51$1@dont-email.me> <v4l5p1$3lqic$10@dont-email.me>
<v4ll54$3sd11$1@dont-email.me> <v4lra6$3t7b2$2@dont-email.me>
<v4mcda$99f$1@dont-email.me> <83sexcll5x.fsf@helmutwaitzmann.news.arcor.de>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Injection-Date: Mon, 17 Jun 2024 08:30:55 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="d070642afdec4e1c027704024e3cba98";
logging-data="564475"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/UufkeVaqHBmq0rJlJFdhN"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:x3+Xx3DakAVx9o+LVp19IE49Gik=
In-Reply-To: <83sexcll5x.fsf@helmutwaitzmann.news.arcor.de>
X-Enigmail-Draft-Status: N1110
View all headers

On 16.06.2024 21:52, Helmut Waitzmann wrote:
> Janis Papanagnou <janis_papanagnou+ng@hotmail.com>:
>> How would the main function look like that I could embed in my call to
>> make a numerically sorted list. Say, something like, for example,
>>
>> viewer $( p_sort P*.HTM )
>>
>> where p_sort would be the Python code. - Note: this is no appropriate
>> solution since it would anyway not work correctly for file names with
>> embedded blanks and newlines. I just want to get a closer
>> understanding how you think this would be usable in shell (or from
>> shell). Thanks.
>
> If ‘p_sort’ is designed to output the sorted file names separated by an
> ASCII NUL character rather than a newline then, using the GNU version of
> ‘xargs’, one can feed that output into ‘xargs’:
>
> {
> p_sort P*.HTM 3<&- |
> xargs --null --no-run-if-empty -- sh -c \
> 'exec 0<&3 3<&- "$@"' sh \
> viewer
> } 3<&0
>
>
> This will avoid the problems with funny characters (including blanks and
> linefeeds) in filenames processed by the shell.

I'm sure it does. You've actually shown a way to circumvent all the
issues with $( ... ) . So I'd probably write a wrapper to make that
code usable in a simpler way. Thanks.

And for the 'p_sort' function I'll resort to some standard tools...

Janis

Subject: Re: Numerically sorted arguments (in shell)
From: Janis Papanagnou
Newsgroups: comp.unix.shell
Organization: A noiseless patient Spider
Date: Mon, 17 Jun 2024 06:32 UTC
References: 1 2 3 4 5 6
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: janis_papanagnou+ng@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell
Subject: Re: Numerically sorted arguments (in shell)
Date: Mon, 17 Jun 2024 08:32:21 +0200
Organization: A noiseless patient Spider
Lines: 14
Message-ID: <v4ol9m$h7ir$1@dont-email.me>
References: <v4grk8$2pp51$1@dont-email.me> <v4l5p1$3lqic$10@dont-email.me>
<v4ll54$3sd11$1@dont-email.me> <v4lra6$3t7b2$2@dont-email.me>
<v4mcda$99f$1@dont-email.me> <v4oid0$gnmb$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Injection-Date: Mon, 17 Jun 2024 08:32:23 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="d070642afdec4e1c027704024e3cba98";
logging-data="564827"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX191gqU+mruVlueA/YZ3UR7v"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:Dkh0/6X8q7Ki7tZZzMyLqD3nZKI=
In-Reply-To: <v4oid0$gnmb$1@dont-email.me>
X-Enigmail-Draft-Status: N1110
View all headers

On 17.06.2024 07:42, Lawrence D'Oliveiro wrote:
> On Sun, 16 Jun 2024 11:48:25 +0200, Janis Papanagnou wrote:
>
>> How would the main function look like that I could embed in my call to
>> make a numerically sorted list.
>
> That’s what the code I posted does.

Erm, really? - I've got the impression that it rather sorts only
the _hard-coded data_, and not to work with arbitrary arguments.
Anyway. Don't bother.

Janis

Subject: Re: Numerically sorted arguments (in shell)
From: Lawrence D'Oliv
Newsgroups: comp.unix.shell
Organization: A noiseless patient Spider
Date: Mon, 17 Jun 2024 07:16 UTC
References: 1 2 3 4 5 6 7
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ldo@nz.invalid (Lawrence D'Oliveiro)
Newsgroups: comp.unix.shell
Subject: Re: Numerically sorted arguments (in shell)
Date: Mon, 17 Jun 2024 07:16:40 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 10
Message-ID: <v4onso$hmlh$1@dont-email.me>
References: <v4grk8$2pp51$1@dont-email.me> <v4l5p1$3lqic$10@dont-email.me>
<v4ll54$3sd11$1@dont-email.me> <v4lra6$3t7b2$2@dont-email.me>
<v4mcda$99f$1@dont-email.me> <v4oid0$gnmb$1@dont-email.me>
<v4ol9m$h7ir$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Mon, 17 Jun 2024 09:16:41 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="1bd7106cd3d92a7299dbf92e56b1d9e0";
logging-data="580273"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+wWd2/ZdCk2/9MVigXh3ui"
User-Agent: Pan/0.158 (Avdiivka; )
Cancel-Lock: sha1:KoHXyQuUqB5DgNU9kOTCm/3Eekw=
View all headers

On Mon, 17 Jun 2024 08:32:21 +0200, Janis Papanagnou wrote:

> ... I've got the impression that it rather sorts only the
> _hard-coded data_ ...

So get the data from the usual sources, e.g. os.listdir().

> Anyway. Don't bother.

I can only lead the horse to water, I cannot make you drink.

Subject: Re: Numerically sorted arguments (in shell)
From: Janis Papanagnou
Newsgroups: comp.unix.shell
Organization: A noiseless patient Spider
Date: Mon, 17 Jun 2024 07:44 UTC
References: 1 2 3 4 5 6 7 8
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: janis_papanagnou+ng@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell
Subject: Re: Numerically sorted arguments (in shell)
Date: Mon, 17 Jun 2024 09:44:55 +0200
Organization: A noiseless patient Spider
Lines: 22
Message-ID: <v4opho$i1r1$1@dont-email.me>
References: <v4grk8$2pp51$1@dont-email.me> <v4l5p1$3lqic$10@dont-email.me>
<v4ll54$3sd11$1@dont-email.me> <v4lra6$3t7b2$2@dont-email.me>
<v4mcda$99f$1@dont-email.me> <v4oid0$gnmb$1@dont-email.me>
<v4ol9m$h7ir$1@dont-email.me> <v4onso$hmlh$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 17 Jun 2024 09:44:56 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="ce947dcd9ea98bb3504b70234e0c429c";
logging-data="591713"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/bPgv4yMV+7Y/dXEThxxUu"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:Cv122+kwjdwDdEcHY7qo7p3y1Ok=
In-Reply-To: <v4onso$hmlh$1@dont-email.me>
X-Enigmail-Draft-Status: N1110
View all headers

On 17.06.2024 09:16, Lawrence D'Oliveiro wrote:
> On Mon, 17 Jun 2024 08:32:21 +0200, Janis Papanagnou wrote:
>
>> ... I've got the impression that it rather sorts only the
>> _hard-coded data_ ...
>
> So get the data from the usual sources, e.g. os.listdir().
>
>> Anyway. Don't bother.
>
> I can only lead the horse to water, I cannot make you drink.

I wouldn't drink from a poisoned spring. IOW; I'd have to learn
Python completely to understand your code and get the details
properly. If it's as simple as you suggested, and since we're
not in a Python NG, I thought you'd have been able to address
the original question with your code (as a black box). In the
present form it's just useless and off-topic here. But as said,
don't bother.

Janis

Subject: Re: Numerically sorted arguments (in shell)
From: Lawrence D'Oliv
Newsgroups: comp.unix.shell
Organization: A noiseless patient Spider
Date: Tue, 18 Jun 2024 08:26 UTC
References: 1 2 3 4 5 6 7 8 9
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ldo@nz.invalid (Lawrence D'Oliveiro)
Newsgroups: comp.unix.shell
Subject: Re: Numerically sorted arguments (in shell)
Date: Tue, 18 Jun 2024 08:26:45 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 12
Message-ID: <v4rgc5$18eq9$7@dont-email.me>
References: <v4grk8$2pp51$1@dont-email.me> <v4l5p1$3lqic$10@dont-email.me>
<v4ll54$3sd11$1@dont-email.me> <v4lra6$3t7b2$2@dont-email.me>
<v4mcda$99f$1@dont-email.me> <v4oid0$gnmb$1@dont-email.me>
<v4ol9m$h7ir$1@dont-email.me> <v4onso$hmlh$1@dont-email.me>
<v4opho$i1r1$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Tue, 18 Jun 2024 10:26:45 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="aa8085ada8e9493580a5b327f88f4c87";
logging-data="1325897"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX182Am5K2T2vW33rRDdEFnwh"
User-Agent: Pan/0.158 (Avdiivka; )
Cancel-Lock: sha1:/b0lqV08O9Dy699hHkcIFAW9IrA=
View all headers

On Mon, 17 Jun 2024 09:44:55 +0200, Janis Papanagnou wrote:

> IOW; I'd have to learn Python completely to understand your code and get
> the details properly.

I give you a fish, you eat for a day. You learn to fish, you eat for a
lifetime.

> In the present form it's just useless and off-topic here. But as said,
> don't bother.

Have you received a better offer yet?

Subject: Re: Numerically sorted arguments (in shell)
From: Kenny McCormack
Newsgroups: comp.unix.shell
Organization: The official candy of the new Millennium
Date: Tue, 18 Jun 2024 11:14 UTC
References: 1 2 3 4
Path: eternal-september.org!news.eternal-september.org!feeder3.eternal-september.org!panix!weretis.net!feeder9.news.weretis.net!xmission!nnrp.xmission!.POSTED.shell.xmission.com!not-for-mail
From: gazelle@shell.xmission.com (Kenny McCormack)
Newsgroups: comp.unix.shell
Subject: Re: Numerically sorted arguments (in shell)
Date: Tue, 18 Jun 2024 11:14:19 -0000 (UTC)
Organization: The official candy of the new Millennium
Message-ID: <v4rq6b$2d0pl$1@news.xmission.com>
References: <v4grk8$2pp51$1@dont-email.me> <v4onso$hmlh$1@dont-email.me> <v4opho$i1r1$1@dont-email.me> <v4rgc5$18eq9$7@dont-email.me>
Injection-Date: Tue, 18 Jun 2024 11:14:19 -0000 (UTC)
Injection-Info: news.xmission.com; posting-host="shell.xmission.com:166.70.8.4";
logging-data="2523957"; mail-complaints-to="abuse@xmission.com"
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: gazelle@shell.xmission.com (Kenny McCormack)
View all headers

In article <v4rgc5$18eq9$7@dont-email.me>,
Lawrence D'Oliveiro <ldo@nz.invalid> wrote:
>On Mon, 17 Jun 2024 09:44:55 +0200, Janis Papanagnou wrote:
>
>> IOW; I'd have to learn Python completely to understand your code and get
>> the details properly.
>
>I give you a fish, you eat for a day. You learn to fish, you eat for a
>lifetime.
>
>> In the present form it's just useless and off-topic here. But as said,
>> don't bother.
>
>Have you received a better offer yet?

Sounds like somebody's fee-fees got hurt here.

--
"Only a genius could lose a billion dollars running a casino."
"You know what they say: the house always loses."
"When life gives you lemons, don't pay taxes."
"Grab 'em by the p***y!"

Subject: Re: Numerically sorted arguments (in shell)
From: Geoff Clare
Newsgroups: comp.unix.shell
Date: Tue, 18 Jun 2024 12:32 UTC
References: 1 2 3 4 5 6
Path: eternal-september.org!news.eternal-september.org!feeder3.eternal-september.org!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: geoff@clare.See-My-Signature.invalid (Geoff Clare)
Newsgroups: comp.unix.shell
Subject: Re: Numerically sorted arguments (in shell)
Date: Tue, 18 Jun 2024 13:32:06 +0100
Lines: 25
Message-ID: <6bb8kk-pks.ln1@ID-313840.user.individual.net>
References: <v4grk8$2pp51$1@dont-email.me> <v4l5p1$3lqic$10@dont-email.me>
<v4ll54$3sd11$1@dont-email.me> <v4lra6$3t7b2$2@dont-email.me>
<v4mcda$99f$1@dont-email.me> <83sexcll5x.fsf@helmutwaitzmann.news.arcor.de>
Reply-To: netnews@gclare.org.uk
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Trace: individual.net z58EvoQgAu/1X/40DGh5fQKSQoUDfNDu5k3TWVO+6FKWat2tbr
X-Orig-Path: ID-313840.user.individual.net!not-for-mail
Cancel-Lock: sha1:GHvz5cslbS/E5IhA6HPMfGu61F0= sha256:2E/sAIOeh1NrJfgS0c+trBul3f0akO66mgeHs9FF3w8=
User-Agent: Pan/0.154 (Izium; 517acf4)
View all headers

Helmut Waitzmann wrote:

> If ‘p_sort’ is designed to output the sorted file names separated
> by an ASCII NUL character rather than a newline then, using the
> GNU version of ‘xargs’, one can feed that output into ‘xargs’:
>
> {
> p_sort P*.HTM 3<&- |
> xargs --null --no-run-if-empty -- sh -c \
> 'exec 0<&3 3<&- "$@"' sh \
> viewer
> } 3<&0

NUL as a record separator is also supported by several other versions
of xargs, and it is in the recently released POSIX.1-2024 standard.
In all of those it is specified with -0, so using -0 is more
portable than the GNU-specific --null.

POSIX.1-2024 also has -r although I think that's not as widely
supported in current xargs implementations as -0. It should become
better supported over time, though, so again I would suggest using -r
rather than --no-run-if-empty for better future portability.

--
Geoff Clare <netnews@gclare.org.uk>

Subject: Re: Numerically sorted arguments (in shell)
From: Chris Elvidge
Newsgroups: comp.unix.shell
Organization: A noiseless patient Spider
Date: Tue, 18 Jun 2024 13:32 UTC
References: 1
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: chris@x550c.mshome.net (Chris Elvidge)
Newsgroups: comp.unix.shell
Subject: Re: Numerically sorted arguments (in shell)
Date: Tue, 18 Jun 2024 14:32:15 +0100
Organization: A noiseless patient Spider
Lines: 71
Message-ID: <v4s28v$1cbch$1@dont-email.me>
References: <v4grk8$2pp51$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 18 Jun 2024 15:32:15 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="3f1e0c3d31fd183ecfbf0fbea961572f";
logging-data="1453457"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/CBeCeeTpwn3hPi1tIS4ofXH4lDYHgPWY="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101
Thunderbird/52.2.1 Lightning/5.4
Cancel-Lock: sha1:rbVjg/YGBIvg85xXDumTKkU3fmk=
Content-Language: en-GB
In-Reply-To: <v4grk8$2pp51$1@dont-email.me>
View all headers

On 14/06/2024 at 08:31, Janis Papanagnou wrote:
> I'm using ksh here...
>
> I can set the shell parameters in numerical order
>
> $ set {1..100}
>
> then sort them _lexicographically_
>
> $ set -s
>
> Or do both in one
>
> $ set -s {1..100}
>
> I haven't found anything to sort them _numerically_ in shell.
>
> What I'm trying to do is iterating over files, say,
> P1.HTM P10.HTM P11.HTM P2.HTM P3.HTM P4.HTM P5.HTM P6.HTM P7.HTM
> P8.HTM P9.HTM
> in numerical order.
>
> Setting the files as shell arguments with P*.HTM will also produce
> lexicographical order.
>
> The preceding files are just samples. It should work also if the
> numbers are non-consecutive (say, 2, 10, 10000, 3333333) so that
> iterating using a for-loop and building the list is not an option.
>
> (Ideally I'd also like to handle names with two numbers "A35P56.txt"
> and irregular string components (lowercase, say, "page310ch1.txt"),
> but that's just a nice-to-have. - I might make use of 'sort'?)
>
>
> But the primary question is; how to organize/iterate the arguments
> *numerically* _in shell_? (If that's possible in some simple way.)
>
>
> N.B.: I prefer not to use external commands like 'sort' because of
> the negative side effects and bulky code to handle newlines and
> blanks in filenames, and messing around with quotes.
>
> Janis
>

Can you use an array? E.g. (bash, I don't know ksh, but could be similar)

for i in P1.HTM P10.HTM P11.HTM P2.HTM P3.HTM P4.HTM P5.HTM P6.HTM
P7.HTM P8.HTM P9.HTM; do
j=${i//[![:digit:]]}
files[j]="$i"
done
printf '%s\n' "${files[@]}"
P1.HTM
P2.HTM
P3.HTM
P4.HTM
P5.HTM
P6.HTM
P7.HTM
P8.HTM
P9.HTM
P10.HTM
P11.HTM

I'll have to work on names with two (or more?) numbers.

--
Chris Elvidge, England
BART BUCKS, ARE NOT LEGAL TENDER

Subject: Re: Numerically sorted arguments (in shell)
From: Janis Papanagnou
Newsgroups: comp.unix.shell
Organization: A noiseless patient Spider
Date: Tue, 18 Jun 2024 14:27 UTC
References: 1 2 3 4 5 6 7 8 9 10
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: janis_papanagnou+ng@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell
Subject: Re: Numerically sorted arguments (in shell)
Date: Tue, 18 Jun 2024 16:27:33 +0200
Organization: A noiseless patient Spider
Lines: 16
Message-ID: <v4s5gm$1cv5s$1@dont-email.me>
References: <v4grk8$2pp51$1@dont-email.me> <v4l5p1$3lqic$10@dont-email.me>
<v4ll54$3sd11$1@dont-email.me> <v4lra6$3t7b2$2@dont-email.me>
<v4mcda$99f$1@dont-email.me> <v4oid0$gnmb$1@dont-email.me>
<v4ol9m$h7ir$1@dont-email.me> <v4onso$hmlh$1@dont-email.me>
<v4opho$i1r1$1@dont-email.me> <v4rgc5$18eq9$7@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 18 Jun 2024 16:27:34 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="5688cbe9191d9f2c921f13829f6efad2";
logging-data="1473724"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+YxOd/ZfYy8ftD6yF9pF5F"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:x4xNER9mCgW4+ILVipWmAZ+8huc=
X-Enigmail-Draft-Status: N1110
In-Reply-To: <v4rgc5$18eq9$7@dont-email.me>
View all headers

On 18.06.2024 10:26, Lawrence D'Oliveiro wrote:
>
>> In the present form it's just useless and off-topic here. But as said,
>> don't bother.
>
> Have you received a better offer yet?

Better than /dev/random ? - No, not yet. But thanks for trying.

(You gave the impression that using python would be "better".
Obviously it isn't. - Why buy a non-standard tool/solution if
I can solve the task with standard Unix tools myself. So don't
bother.)

Janis

Subject: Re: Numerically sorted arguments (in shell)
From: Janis Papanagnou
Newsgroups: comp.unix.shell
Organization: A noiseless patient Spider
Date: Tue, 18 Jun 2024 14:38 UTC
References: 1 2
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: janis_papanagnou+ng@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell
Subject: Re: Numerically sorted arguments (in shell)
Date: Tue, 18 Jun 2024 16:38:30 +0200
Organization: A noiseless patient Spider
Lines: 79
Message-ID: <v4s658$1d2u7$1@dont-email.me>
References: <v4grk8$2pp51$1@dont-email.me> <v4s28v$1cbch$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 18 Jun 2024 16:38:32 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="5688cbe9191d9f2c921f13829f6efad2";
logging-data="1477575"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18rQdlqwlbKRraC4Ix1WFzl"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:Hr0IejQTSyC3uR4+WxV9gV+qbQs=
In-Reply-To: <v4s28v$1cbch$1@dont-email.me>
X-Enigmail-Draft-Status: N1110
View all headers

On 18.06.2024 15:32, Chris Elvidge wrote:
> On 14/06/2024 at 08:31, Janis Papanagnou wrote:
>> I'm using ksh here...
>>
>> I can set the shell parameters in numerical order
>>
>> $ set {1..100}
>>
>> then sort them _lexicographically_
>>
>> $ set -s
>>
>> Or do both in one
>>
>> $ set -s {1..100}
>>
>> I haven't found anything to sort them _numerically_ in shell.
>>
>> What I'm trying to do is iterating over files, say,
>> P1.HTM P10.HTM P11.HTM P2.HTM P3.HTM P4.HTM P5.HTM P6.HTM P7.HTM
>> P8.HTM P9.HTM
>> in numerical order.
>>
>> Setting the files as shell arguments with P*.HTM will also produce
>> lexicographical order.
>>
>> The preceding files are just samples. It should work also if the
>> numbers are non-consecutive (say, 2, 10, 10000, 3333333) so that
>> iterating using a for-loop and building the list is not an option.
>>
>> (Ideally I'd also like to handle names with two numbers "A35P56.txt"
>> and irregular string components (lowercase, say, "page310ch1.txt"),
>> but that's just a nice-to-have. - I might make use of 'sort'?)
>>
>>
>> But the primary question is; how to organize/iterate the arguments
>> *numerically* _in shell_? (If that's possible in some simple way.)
>>
>>
>> N.B.: I prefer not to use external commands like 'sort' because of
>> the negative side effects and bulky code to handle newlines and
>> blanks in filenames, and messing around with quotes.
>>
>> Janis
>>
>
> Can you use an array? E.g. (bash, I don't know ksh, but could be similar)

Yes, Ksh supports both, indexed and associative arrays.

>
> for i in P1.HTM P10.HTM P11.HTM P2.HTM P3.HTM P4.HTM P5.HTM P6.HTM
> P7.HTM P8.HTM P9.HTM; do
> j=${i//[![:digit:]]}
> files[j]="$i"
> done
> printf '%s\n' "${files[@]}"
> P1.HTM
> P2.HTM
> P3.HTM
> P4.HTM
> P5.HTM
> P6.HTM
> P7.HTM
> P8.HTM
> P9.HTM
> P10.HTM
> P11.HTM
>
> I'll have to work on names with two (or more?) numbers.

One thing that concerns me with arrays is that I seem to recall that
there was a limit in the number of array elements (which might be an
issue on lengthy lists of files). But some ad hoc tests seem to show
that if there's a limit it's not any more in the 1k/4k elements range
as it had been. (Bolski/Korn says their arrays support at least 4k.)

Janis

Subject: Re: Numerically sorted arguments (in shell)
From: Chris Elvidge
Newsgroups: comp.unix.shell
Organization: A noiseless patient Spider
Date: Tue, 18 Jun 2024 15:19 UTC
References: 1 2 3
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: chris@x550c.mshome.net (Chris Elvidge)
Newsgroups: comp.unix.shell
Subject: Re: Numerically sorted arguments (in shell)
Date: Tue, 18 Jun 2024 16:19:45 +0100
Organization: A noiseless patient Spider
Lines: 106
Message-ID: <v4s8ij$1dh3e$1@dont-email.me>
References: <v4grk8$2pp51$1@dont-email.me> <v4s28v$1cbch$1@dont-email.me>
<v4s658$1d2u7$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 18 Jun 2024 17:19:47 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="5f71a90700586b5fd6cb75340298a2b0";
logging-data="1492078"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/hicIZmp62fDZXn2S+9zDMHh8XFmbamWc="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101
Thunderbird/52.2.1 Lightning/5.4
Cancel-Lock: sha1:qbzgd9SiwrTWoSXg/GAGQ7M6KLc=
Content-Language: en-GB
In-Reply-To: <v4s658$1d2u7$1@dont-email.me>
View all headers

On 18/06/2024 at 15:38, Janis Papanagnou wrote:
> On 18.06.2024 15:32, Chris Elvidge wrote:
>> On 14/06/2024 at 08:31, Janis Papanagnou wrote:
>>> I'm using ksh here...
>>>
>>> I can set the shell parameters in numerical order
>>>
>>> $ set {1..100}
>>>
>>> then sort them _lexicographically_
>>>
>>> $ set -s
>>>
>>> Or do both in one
>>>
>>> $ set -s {1..100}
>>>
>>> I haven't found anything to sort them _numerically_ in shell.
>>>
>>> What I'm trying to do is iterating over files, say,
>>> P1.HTM P10.HTM P11.HTM P2.HTM P3.HTM P4.HTM P5.HTM P6.HTM P7.HTM
>>> P8.HTM P9.HTM
>>> in numerical order.
>>>
>>> Setting the files as shell arguments with P*.HTM will also produce
>>> lexicographical order.
>>>
>>> The preceding files are just samples. It should work also if the
>>> numbers are non-consecutive (say, 2, 10, 10000, 3333333) so that
>>> iterating using a for-loop and building the list is not an option.
>>>
>>> (Ideally I'd also like to handle names with two numbers "A35P56.txt"
>>> and irregular string components (lowercase, say, "page310ch1.txt"),
>>> but that's just a nice-to-have. - I might make use of 'sort'?)
>>>
>>>
>>> But the primary question is; how to organize/iterate the arguments
>>> *numerically* _in shell_? (If that's possible in some simple way.)
>>>
>>>
>>> N.B.: I prefer not to use external commands like 'sort' because of
>>> the negative side effects and bulky code to handle newlines and
>>> blanks in filenames, and messing around with quotes.
>>>
>>> Janis
>>>
>>
>> Can you use an array? E.g. (bash, I don't know ksh, but could be similar)
>
> Yes, Ksh supports both, indexed and associative arrays.
>
>>
>> for i in P1.HTM P10.HTM P11.HTM P2.HTM P3.HTM P4.HTM P5.HTM P6.HTM
>> P7.HTM P8.HTM P9.HTM; do
>> j=${i//[![:digit:]]}
>> files[j]="$i"
>> done
>> printf '%s\n' "${files[@]}"
>> P1.HTM
>> P2.HTM
>> P3.HTM
>> P4.HTM
>> P5.HTM
>> P6.HTM
>> P7.HTM
>> P8.HTM
>> P9.HTM
>> P10.HTM
>> P11.HTM
>>
>> I'll have to work on names with two (or more?) numbers.
>
> One thing that concerns me with arrays is that I seem to recall that
> there was a limit in the number of array elements (which might be an
> issue on lengthy lists of files). But some ad hoc tests seem to show
> that if there's a limit it's not any more in the 1k/4k elements range
> as it had been. (Bolski/Korn says their arrays support at least 4k.)
>
> Janis
>

I tested in ksh - works as written.

From here:
https://unix.stackexchange.com/questions/195191/ksh-bash-maximum-size-of-an-array

<quote>

This simple script shows on my systems (Gnu/Linux and Solaris):

ksh88 limits the size to 2^12-1 (4095). (subscript out of range ).
Some older releases like the one on HP-UX limit the size to 1023.

ksh93 limits the size of a array to 2^22-1 (4194303), your mileage
may vary.

bash doesn't look to impose any hard-coded limit outside the one
dictated by the underlying memory resources available. For example bash
uses 1.3 GB of virtual memory for an array size of 18074340.

</quote>

--
Chris Elvidge, England
BART BUCKS, ARE NOT LEGAL TENDER

Subject: Re: Numerically sorted arguments (in shell)
From: Janis Papanagnou
Newsgroups: comp.unix.shell
Organization: A noiseless patient Spider
Date: Tue, 18 Jun 2024 17:04 UTC
References: 1
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: janis_papanagnou+ng@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell
Subject: Re: Numerically sorted arguments (in shell)
Date: Tue, 18 Jun 2024 19:04:41 +0200
Organization: A noiseless patient Spider
Lines: 76
Message-ID: <v4sena$1eqki$1@dont-email.me>
References: <v4grk8$2pp51$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 18 Jun 2024 19:04:43 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="5688cbe9191d9f2c921f13829f6efad2";
logging-data="1534610"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19M0kfuG5xePELeqTIfzZB/"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:u30VC7oYK13naxh3SAeCS7QsX1s=
X-Enigmail-Draft-Status: N1110
In-Reply-To: <v4grk8$2pp51$1@dont-email.me>
View all headers

I've just tried a Unix tools based solution (with sed, sort, cut).

Up to and including the line containing 'shuf' is data generation,
the rest (starting with 'sed') extracts and sorts the data. I've
written it for TWO numeric sort keys (see printf format specifier)

for (( i=1; i<=50; i++ ))
do
for (( j=2; j<=120; j+=3 ))
do
printf "a%db%dc.txt\n" i j
done
done |
shuf |

sed 's/[^0-9]*\([0-9]\+\)[^0-9]*\([0-9]\+\)[^0-9]*/\1\t\2\t&/' |
sort -t$'\t' -k1n -k2n |
cut -f3-

For just one numeric argument this can be simplified (shorter sed
pattern, simpler sort -n command), and for more than two numeric
fields it can be modified to dynamically construct the sed pattern,
the sort option list, and the cut parameter, once at the beginning;
that way we could have a tool for arbitrary amounts of numeric keys
in the file name.

Note: this program doesn't handle pathological filenames (newlines).

Janis

On 14.06.2024 09:31, Janis Papanagnou wrote:
> I'm using ksh here...
>
> I can set the shell parameters in numerical order
>
> $ set {1..100}
>
> then sort them _lexicographically_
>
> $ set -s
>
> Or do both in one
>
> $ set -s {1..100}
>
> I haven't found anything to sort them _numerically_ in shell.
>
> What I'm trying to do is iterating over files, say,
> P1.HTM P10.HTM P11.HTM P2.HTM P3.HTM P4.HTM P5.HTM P6.HTM P7.HTM
> P8.HTM P9.HTM
> in numerical order.
>
> Setting the files as shell arguments with P*.HTM will also produce
> lexicographical order.
>
> The preceding files are just samples. It should work also if the
> numbers are non-consecutive (say, 2, 10, 10000, 3333333) so that
> iterating using a for-loop and building the list is not an option.
>
> (Ideally I'd also like to handle names with two numbers "A35P56.txt"
> and irregular string components (lowercase, say, "page310ch1.txt"),
> but that's just a nice-to-have. - I might make use of 'sort'?)
>
>
> But the primary question is; how to organize/iterate the arguments
> *numerically* _in shell_? (If that's possible in some simple way.)
>
>
> N.B.: I prefer not to use external commands like 'sort' because of
> the negative side effects and bulky code to handle newlines and
> blanks in filenames, and messing around with quotes.
>
> Janis
>

Subject: Re: Numerically sorted arguments (in shell)
From: Janis Papanagnou
Newsgroups: comp.unix.shell
Organization: A noiseless patient Spider
Date: Tue, 18 Jun 2024 17:12 UTC
References: 1 2 3 4
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: janis_papanagnou+ng@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell
Subject: Re: Numerically sorted arguments (in shell)
Date: Tue, 18 Jun 2024 19:12:20 +0200
Organization: A noiseless patient Spider
Lines: 47
Message-ID: <v4sf5l$1eu4h$1@dont-email.me>
References: <v4grk8$2pp51$1@dont-email.me> <v4s28v$1cbch$1@dont-email.me>
<v4s658$1d2u7$1@dont-email.me> <v4s8ij$1dh3e$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 18 Jun 2024 19:12:22 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="5688cbe9191d9f2c921f13829f6efad2";
logging-data="1538193"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+pe+EgPrvK0xXvyOTUfVhv"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:6Bgh2Thamv2ap4mR7heF51kAicc=
X-Enigmail-Draft-Status: N1110
In-Reply-To: <v4s8ij$1dh3e$1@dont-email.me>
View all headers

On 18.06.2024 17:19, Chris Elvidge wrote:
> On 18/06/2024 at 15:38, Janis Papanagnou wrote:
[...]
>> One thing that concerns me with arrays is that I seem to recall that
>> there was a limit in the number of array elements (which might be an
>> issue on lengthy lists of files). But some ad hoc tests seem to show
>> that if there's a limit it's not any more in the 1k/4k elements range
>> as it had been. (Bolski/Korn says their arrays support at least 4k.)
>
> I tested in ksh - works as written.
>
> From here:
> https://unix.stackexchange.com/questions/195191/ksh-bash-maximum-size-of-an-array
>
>
> <quote>
>
> This simple script shows on my systems (Gnu/Linux and Solaris):
>
> ksh88 limits the size to 2^12-1 (4095). (subscript out of range ).
> Some older releases like the one on HP-UX limit the size to 1023.

Yeah, I recall these limits from ksh88 on AIX and HP-UX.

>
> ksh93 limits the size of a array to 2^22-1 (4194303), your mileage
> may vary.

I've tried on my system just with a million names (yet more
filenames than we want to have in our directories in one place).

>
> bash doesn't look to impose any hard-coded limit outside the one
> dictated by the underlying memory resources available. For example bash
> uses 1.3 GB of virtual memory for an array size of 18074340.

I didn't notice a limit for my old Bash or Ksh on my system.

So your array approach looks promising for one numeric key, and
it's a nice and terse solution.

Janis

>
> </quote>
>

Subject: Re: Numerically sorted arguments (in shell)
From: Janis Papanagnou
Newsgroups: comp.unix.shell
Organization: A noiseless patient Spider
Date: Tue, 18 Jun 2024 17:23 UTC
References: 1 2 3 4 5
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: janis_papanagnou+ng@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell
Subject: Re: Numerically sorted arguments (in shell)
Date: Tue, 18 Jun 2024 19:23:33 +0200
Organization: A noiseless patient Spider
Lines: 10
Message-ID: <v4sfqm$1f2kf$1@dont-email.me>
References: <v4grk8$2pp51$1@dont-email.me> <v4s28v$1cbch$1@dont-email.me>
<v4s658$1d2u7$1@dont-email.me> <v4s8ij$1dh3e$1@dont-email.me>
<v4sf5l$1eu4h$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 18 Jun 2024 19:23:34 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="5688cbe9191d9f2c921f13829f6efad2";
logging-data="1542799"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+6gdk0ERwGNjPijjA4qlWq"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:JVoPyZEApQ2IuGHntf05LRw1rWg=
In-Reply-To: <v4sf5l$1eu4h$1@dont-email.me>
View all headers

On 18.06.2024 19:12, Janis Papanagnou wrote:
>
> So your array approach looks promising for one numeric key, and
> it's a nice and terse solution.

Forgot to praise its nice property to also handle newlines in the
filenames.

> Janis

Pages:12

rocksolid light 0.9.8
clearnet tor