14

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.

Oliver Salzburg
  • 89,072
  • 65
  • 269
  • 311

2 Answers2

19

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).

It's called Brace Expansion:
https://www.gnu.org/software/bash/manual/html_node/Brace-Expansion.html

otocan
  • 291
7

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

fede.evol
  • 1,946