3 ms·
zsh: setopt extendedglob allows you to use numeric ranges on globbing with < >: mv p1080<100-300>.jpg folderx/ to move p1080100.jpg through p1080300.jpg to a
by woodchuck64 14y ago
zsh: setopt extendedglob allows you to use numeric ranges on globbing with < >:
mv p1080<100-300>.jpg folderx/
to move p1080100.jpg through p1080300.jpg to a new folder.
Still not available on bash or more common shells?
- LukeShu 14y agoBash: mv p1080{100..300}.jpg folderx/
- 1amzave 14y agoThough that's not strictly a glob, but brace expansion (it will expand to all the numbers in that range regardless of whether or not files with those names exist). bash does have 'shopt -s extglob', which enables a number of useful globbing extensions, though I don't believe there are any numeric ones among them.
- woodchuck64 14y agoTIL, thank you. Here it is from the manpage: A sequence expression takes the form {x..y[..incr]}, where x and y are either integers or single characters, and incr, an optional increment, is an integer. When integers are supplied, the expression expands to each number between x and y, inclusive. Supplied integers may be pre‐fixed with 0 to force each term to have the same width. When either x or y begins with a zero, the shell attempts to force all generated terms to contain the same number of digits, zero-padding where necessary. When characters are supplied, the expression expands to each character lexicographically between x and y, inclusive. Note that both x and y must be of the same type. When the increment is supplied, it is used as the difference between each term. The default increment is 1 or -1 as appropriate.