* 'for' sorted? @ 2022-09-22 15:19 Ray Andrews 2022-09-22 15:26 ` Jérémie Roquet 0 siblings, 1 reply; 7+ messages in thread From: Ray Andrews @ 2022-09-22 15:19 UTC (permalink / raw) To: Zsh Users for var in /dev/sd*; do ... Apart from capturing the output and then sorting it, is is possible for 'for' to go thru the input in a sorted way? I doubt it but she moves in mysterious ways so it might just be doable. ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: 'for' sorted? 2022-09-22 15:19 'for' sorted? Ray Andrews @ 2022-09-22 15:26 ` Jérémie Roquet 2022-09-22 15:54 ` Ray Andrews 0 siblings, 1 reply; 7+ messages in thread From: Jérémie Roquet @ 2022-09-22 15:26 UTC (permalink / raw) To: Ray Andrews; +Cc: Zsh Users Hi, Le jeu. 22 sept. 2022 à 17:20, Ray Andrews <rayandrews@eastlink.ca> a écrit : > for var in /dev/sd*; do > ... > > Apart from capturing the output and then sorting it, is is possible for > 'for' to go thru the input in a sorted way? I doubt it but she moves in > mysterious ways so it might just be doable. 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, -- Jérémie ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: 'for' sorted? 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:17 ` Andreas Kusalananda Kähäri 0 siblings, 2 replies; 7+ messages in thread From: Ray Andrews @ 2022-09-22 15:54 UTC (permalink / raw) To: zsh-users 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 ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: 'for' sorted? 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 1 sibling, 1 reply; 7+ messages in thread From: Mikael Magnusson @ 2022-09-22 16:12 UTC (permalink / raw) To: Ray Andrews; +Cc: zsh-users On 9/22/22, Ray Andrews <rayandrews@eastlink.ca> 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 You can use the n glob qualifier for this. (distinct from the n option to the o glob qualifier). eg, *(non) -- Mikael Magnusson ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: 'for' sorted? 2022-09-22 16:12 ` Mikael Magnusson @ 2022-09-22 16:25 ` Ray Andrews 0 siblings, 0 replies; 7+ messages in thread From: Ray Andrews @ 2022-09-22 16:25 UTC (permalink / raw) To: zsh-users On 2022-09-22 09:12, Mikael Magnusson wrote: > > You can use the n glob qualifier for this. (distinct from the n option > to the o glob qualifier). eg, *(non) > Perfect! You know, it amazes me that there is enough semantic real estate for zsh to be able to accept such a fine level of control without ambiguities. I'd like to dive into it, but it would take a hundred hours of instruction to get me up to speed. ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: 'for' sorted? 2022-09-22 15:54 ` Ray Andrews 2022-09-22 16:12 ` Mikael Magnusson @ 2022-09-22 16:17 ` Andreas Kusalananda Kähäri 2022-09-22 16:30 ` Ray Andrews 1 sibling, 1 reply; 7+ messages in thread From: Andreas Kusalananda Kähäri @ 2022-09-22 16:17 UTC (permalink / raw) To: Ray Andrews; +Cc: zsh-users 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 . ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: 'for' sorted? 2022-09-22 16:17 ` Andreas Kusalananda Kähäri @ 2022-09-22 16:30 ` Ray Andrews 0 siblings, 0 replies; 7+ messages in thread From: Ray Andrews @ 2022-09-22 16:30 UTC (permalink / raw) To: zsh-users On 2022-09-22 09:17, Andreas Kusalananda Kähäri wrote: > > The number at the end of device files are not version numbers. Obviously! But version sort gives the kind of order I'm looking for. > > > print -l /dev/sda*(n) > > or, > > setopt NUMERIC_GLOB_SORT > print -l /dev/sda* > > Thanks, that seems just as effective. ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2022-09-22 16:31 UTC | newest] Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2022-09-22 15:19 'for' sorted? 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 2022-09-22 16:30 ` Ray Andrews
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).