Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: pad numbers



On Sat, Nov 15, 2008 at 11:04:25AM -0800, Phil Pennock wrote:
[...]
> Recreating the original files, then:
> % zmv '([[:digit:]]|[[:digit:]][[:digit:]])([^[:digit:]]*)' '${(l:3::0:)1}$2'
> % ls
> 001 - Foo   002 - Bar   003 - Baz   100 - Fred  2000 - Long

Or:

zmv -n '(<0-999>)(*)' '${(l:3::0:)1}$2'

Which BTW changes "00002 - X" to "002 - X".

-- 
Stéphane



Messages sorted by: Reverse Date, Date, Thread, Author