From: "Andreas Kusalananda Kähäri" <andreas.kahari@abc.se>
To: Ray Andrews <rayandrews@eastlink.ca>
Cc: zsh-users@zsh.org
Subject: Re: 'for' sorted?
Date: Thu, 22 Sep 2022 18:17:26 +0200 [thread overview]
Message-ID: <YyyKlvNvxCYUNoqn@harpo.local> (raw)
In-Reply-To: <b3f80f38-2fd3-6594-ab63-e9da5ce04b7c@eastlink.ca>
On Thu, Sep 22, 2022 at 08:54:58AM -0700, Ray Andrews wrote:
> On 2022-09-22 08:26, Jérémie Roquet wrote:
> >
> > Lexical order:
> >
> > for var in /dev/sd*(on); do
> >
> > To see the available sort specifiers, use:
> >
> > for var in /dev/sd*(o<tab>
> >
> > Best regards,
> >
> Bloody marvelous, <tab> there to give you your options, I had no idea
> there was any such thing.
>
> 9 /aWorking/Zsh/Source/Wk 1 $ for aa in /dev/sda*(on); do echo $aa; done
> /dev/sda
> /dev/sda1
> /dev/sda10
> /dev/sda11
> /dev/sda12
> /dev/sda13
> /dev/sda2
> /dev/sda3
> /dev/sda4
> /dev/sda5
> /dev/sda6
> /dev/sda7
> /dev/sda8
> /dev/sda9
>
> Now, what would be idyllic is to be able to have version sort so that
> the output is this:
>
> /dev/sda
> /dev/sda1
> /dev/sda2
> /dev/sda3
> /dev/sda4
> /dev/sda5
> /dev/sda6
> /dev/sda7
> /dev/sda8
> /dev/sda9
> /dev/sda10
> /dev/sda11
> /dev/sda12
> /dev/sda13
>
>
> Thanks Jérémie
The number at the end of device files are not version numbers.
To get them in numerical order instead of the default lexicographical
order, use (n) as the globbing qualifier, or set the NUMERIC_GLOB_SORT
shell option.
print -l /dev/sda*(n)
or,
setopt NUMERIC_GLOB_SORT
print -l /dev/sda*
--
Andreas (Kusalananda) Kähäri
SciLifeLab, NBIS, ICM
Uppsala University, Sweden
.
next prev parent reply other threads:[~2022-09-22 16:19 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-22 15:19 Ray Andrews
2022-09-22 15:26 ` Jérémie Roquet
2022-09-22 15:54 ` Ray Andrews
2022-09-22 16:12 ` Mikael Magnusson
2022-09-22 16:25 ` Ray Andrews
2022-09-22 16:17 ` Andreas Kusalananda Kähäri [this message]
2022-09-22 16:30 ` Ray Andrews
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=YyyKlvNvxCYUNoqn@harpo.local \
--to=andreas.kahari@abc.se \
--cc=rayandrews@eastlink.ca \
--cc=zsh-users@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).