From: Peter Bailey Date: 2013-01-10T01:23:41+09:00 Subject: Re: One liner for filenames "Jesús Gabriel y Galán" wrote in post #1091613: > On Wed, Jan 9, 2013 at 5:00 PM, Peter Bailey > wrote: >>>> ruby -r pathname -e 'Pathname.glob("*[^1].png").each(&:delete)' >>> >>> Careful, as this skips also filename_11.png, filename_21.png, etc. >>> Building on this: >>> >>> ruby -r pathname -e 'Pathname.glob("*_{[^1],??}.png").each(&:delete)' >>> >>> Jesus. >> >> Excellent. Thanks. Hans is right, though. Dir.glob is unsorted. Is that >> a problem here? > > No, because here we are using the glob facility to do all the > filtering. In the other solution, there was the array returned from > the glob that was being filtered, and so the order was important for > the solution that removed the first entry in the array. > > Jesus. Beautiful. Thanks a lot. -- Posted via http://www.ruby-forum.com/.