Can I use shell wildcards to select filenames ranging across double-digit numbers (e.g., from foo_1.jpg to foo_54.jpg)?

I assume you want to copy these files to another directory.

I assume you want to copy these files to another directory: cp -t target_directory foo_{0..54}.jpg.

1: Like the use of the {0..54}. That's much cleaner than the globbing – David W. Jun 22 '11 at 17:18 You are amazing!

Would you happen to know where in the bash manual that is described? I can't find it but I now remember seeing it somewhere. Nevermind.

Found it under Brace Expansion. – grok12 Jun 22 '11 at 17:21 Apparently this brace expansion sequence expression is used for file name matching but not for regex. – grok12 Jun 22 '11 at 18:34.

Ls foo_0-9. Jpg foo_1-40-9. Jpg foo_50-4.

Jpg Try it with ls and if that looks good to you then do the copy.

50-4}. Jpg . – DigitalRoss Jun 22 '11 at 16:49 1 @DigitalRoss: That's good except it will match files like foo_a.

Jpg if they exist. Perhaps replacing your? 's with 0-9's is the best solution.

– grok12 Jun 22 '11 at 16:54.

For I in `seq 0 54`; do cp foo_$i. Jpg ; done.

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.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions