The Computer Oracle

Linux Bash Shell - File globbing specific range?

--------------------------------------------------
Rise to the top 3% as a developer or hire one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------

Music by Eric Matyas
https://www.soundimage.org
Track title: Puzzle Game 5 Looping

--

Chapters
00:00 Linux Bash Shell - File Globbing Specific Range?
00:34 Answer 1 Score 18
00:55 Accepted Answer Score 8
01:02 Thank you

--

Full question
https://superuser.com/questions/716358/l...

--

Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...

--

Tags
#linux #bash #globbing

#avk47



ANSWER 1

Score 18


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




ACCEPTED ANSWER

Score 8


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