7

I have a bunch of files in a folder:

spreadsheet700.xls spreadsheet800.xls spreadsheet850.xls spreadsheet1005.xls spreadsheet2400.xls

how can I use file globbing to select files that numbers end in 700 or higher, but less than 1000 and put them into a new folder?

I've tried:

cp spreadsheet*.xls but the wildcard selects all. Thanks in adance.

  • Please edit your question to include (and tag) the program language or shell you are using so we don't have to guess. This makes it useful for others who search similar questions. – CharlieRB Feb 13 '14 at 12:45
  • Done - Apologies for not including that info – BubbleMonster Feb 13 '14 at 21:10
3

cp spreadsheet{7,8,9}[0-9][0-9].xls folder

This means starting with 7 or 8 or 9 and with two more digits so therefore 7xx,8xx,9xx

  • Works perfectly, didn't know I could use {} with [] thanks – BubbleMonster Feb 13 '14 at 12:45
  • Also spreadsheet[789][0-9][0-9].xls works the same but I thought the curly brackets make it more evident – fede.evol Feb 13 '14 at 12:47
7

You could also do this:

cp spreadsheet{700..999}.xls folder

This is simpler and also gives you more precision on starting and ending the range (the accepted answer only works if you want to get the same sets of digits for 7xx, 8xx and 9xx).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.