Linux – How to Copy Range of Files in Command Line (ZSH/BASH)

bashcopylinuxzsh

I have a list of files with consecutive numbers as suffixes. I would like to copy only a range of these files. How can I specify a range as part of my cp command.

$ls
P1080272.JPG* P1080273.JPG* P1080274.JPG* P1080275.JPG* P1080276.JPG* P1080277.JPG*
P1080278.JPG* P1080279.JPG* P1080280.JPG* P1080281.JPG* P1080282.JPG* P1080283.JPG*

I would like to copy files from P1080275.JPG to P1080283.JPG with something similar to:

$cp P10802[75-83].JPG ~/Images/.

Is there a way to do this?

Best Answer

You were very close. Your question was almost the correct syntax:

cp P10802{75..83}.JPG ~/Images