Can I use shell wildcards to select filenames ranging across double-digit numbers (e.g., from foo_1.jpg to foo_54.jpg)?
I like glenn jackman answer, but if you really want to use globbing, following might also work for you:
$ shopt -s extglob$ cp foo_+([0-9]).jpg $targetDir
In extended globbing +()
matches one or more instances of whatever expression is in the parentheses.
Now, this will copy ALL files that are named foo_
followed by any number, followed by .jpg
. This will include foo_55.jpg
, foo_139.jpg
, and foo_1223218213123981237987.jpg
.
On second thought, glenn jackman has the better answer. But, it did give me a chance to talk about extended globbing.