Command Line – Download All Files in a Directory

command line

I would like to save my online textbook for offline usage, and through Google Chrome's "Network" panel I found out the path of the images. They can be accessed through the browser and downloaded using curl if given the correct configuration ("copy cURL"). The files look like the following: "https://c.m.com/r*/p*/R*/5*/5*/2*/O*/images/page.svgz", where is the page number with four digits, e.g. page0258.svgz. I would like to batch download them using some shell syntaxes. I use fish, but I can also use other shells.

How would I achieve that four number pattern expansion on the command line?

Best Answer

curl can do this automatically for you (see the beginning of man curl for more details about this):

curl -O https://c.m.com/r*/p*/R*/5*/5*/2*/O*/images/page[0000-9999].svgz

PS: This assumes you will expand r*/p*/R*/5*/5*/2*/O*/ before running curl,