Skip to main content
added 859 characters in body
Source Link
Stéphane Chazelas
  • 584.6k
  • 96
  • 1.1k
  • 1.7k

With zsh:

setopt extendedglob # best in ~/.zshrc
ls -ld -- <126-253>(*.po~[0-9]*)

That is, decimal numbers 126 to 253 (000126 also accepted) followed by something that ends in .po and doesn't start with a decimal digit).

Recursively, including in hidden dirs and only regular files:

ls -ld -- **/<126-253>(*.po~[0-9]*)(D.)

use zargs if you run into the arg list too long error.

To use variables instead of literal numbers, you can't do <$low-$high>. That <x-y> operator overlapping with redirection operators (echo <3-4> z in POSIX shells, runs echo with input redirected from the 3- file and fd 4 going into z), zsh tries to minimize the risk of conflict by accepting only literal digits. You can however use use that operator as part of globsubsting expansions like:

low=126 high=253
ls -ld -- ${~:-"<$low-$high>"}(*.po~[0-9]*)

Where ${~expansion} enable globsubst (allows the expansion to undergo globbing) for the expansion and ${:-"text"} is a special form of ${var:-default} to have an expansion expand to arbitrary text.

With zsh:

setopt extendedglob # best in ~/.zshrc
ls -ld -- <126-253>(*.po~[0-9]*)

Recursively, including in hidden dirs and only regular files:

ls -ld -- **/<126-253>(*.po~[0-9]*)(D.)

use zargs if you run into the arg list too long error.

With zsh:

setopt extendedglob # best in ~/.zshrc
ls -ld -- <126-253>(*.po~[0-9]*)

That is, decimal numbers 126 to 253 (000126 also accepted) followed by something that ends in .po and doesn't start with a decimal digit).

Recursively, including in hidden dirs and only regular files:

ls -ld -- **/<126-253>(*.po~[0-9]*)(D.)

use zargs if you run into the arg list too long error.

To use variables instead of literal numbers, you can't do <$low-$high>. That <x-y> operator overlapping with redirection operators (echo <3-4> z in POSIX shells, runs echo with input redirected from the 3- file and fd 4 going into z), zsh tries to minimize the risk of conflict by accepting only literal digits. You can however use use that operator as part of globsubsting expansions like:

low=126 high=253
ls -ld -- ${~:-"<$low-$high>"}(*.po~[0-9]*)

Where ${~expansion} enable globsubst (allows the expansion to undergo globbing) for the expansion and ${:-"text"} is a special form of ${var:-default} to have an expansion expand to arbitrary text.

added 70 characters in body
Source Link
Stéphane Chazelas
  • 584.6k
  • 96
  • 1.1k
  • 1.7k

With zsh:

setopt extendedglob # best in ~/.zshrc
ls -ld -- <126-253>(|[^0*.po~[0-9]*)

Recursively, including in hidden dirs and only regular files:

ls -ld -- **/<126-253>(|[^0*.po~[0-9]*)(D.)

use zargs if you run into the arg list too long error.

With zsh:

setopt extendedglob # best in ~/.zshrc
ls -ld -- <126-253>(|[^0-9]*)

Recursively, including in hidden dirs and only regular files:

ls -ld -- **/<126-253>(|[^0-9]*)(D.)

With zsh:

setopt extendedglob # best in ~/.zshrc
ls -ld -- <126-253>(*.po~[0-9]*)

Recursively, including in hidden dirs and only regular files:

ls -ld -- **/<126-253>(*.po~[0-9]*)(D.)

use zargs if you run into the arg list too long error.

Source Link
Stéphane Chazelas
  • 584.6k
  • 96
  • 1.1k
  • 1.7k

With zsh:

setopt extendedglob # best in ~/.zshrc
ls -ld -- <126-253>(|[^0-9]*)

Recursively, including in hidden dirs and only regular files:

ls -ld -- **/<126-253>(|[^0-9]*)(D.)