How do I use a hexadecimal range when downloading multiple files in Curl?Load multiple files simulatenously...

Rationale to prefer local variables over instance variables?

How do ISS astronauts "get their stripes"?

Is it possible to keep the Ring of Winter if you manage to acquire it?

Misplaced tyre lever - Alternatives?

When was drinking water recognized as crucial in marathon running?

Why is working on the same position for more than 15 years not a red flag?

Called into a meeting and told we are being made redundant (laid off) and "not to share outside". Can I tell my partner?

Six real numbers so that product of any five is the sixth one

In the comics did Thanos "kill" just sentient beings or all creatures with the snap?

Did 5.25" floppies undergo a change in magnetic coating?

Why is s'abonner reflexive?

Why do phishing e-mails use faked e-mail addresses instead of the real one?

How to kill a localhost:8080

Is divide-by-zero a security vulnerability?

Graphing random points on the XY-plane

Logistics of a hovering watercraft in a fantasy setting

Canadian citizen, on US no-fly list. What can I do in order to be allowed on flights which go through US airspace?

What is knowledge and vision?

Is there a frame of reference in which I was born before I was conceived?

Manipulate scientific format without the "e"

What is a term for a function that when called repeatedly, has the same effect as calling once?

What are all the squawk codes?

How to deal with being jealous of your own players?

If a set is open, does that imply that it has no boundary points?



How do I use a hexadecimal range when downloading multiple files in Curl?


Load multiple files simulatenously with cURLDownloading only images using curl or wget?Curl ignores the -r switch when -C is presentHow can I use Wget / Curl / Plowshare to download from 1fichier.com as a premium member?Multiple input files and output files in awkcurl check if file is newer and instead of downloading - execute a bash (or python) scriptHow to use CURL tool?Curl command to download a file over HTTPSHow to: concurrent cURL downloads?How to curl download and extract file only when file is modified?













1















I know that I can download a sequence of files using decimal numbers in curl:



curl site.com/file[000-100].jpg -o "file#.jpg"


But I need to download a hexadecimal series of files named file0x000 to file0x254. Can I specify this in one command line? Or can someone help me with a bash script?










share|improve this question









New contributor




Alan in Oakland is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
















  • 1





    Did you mean file0x000 to file0x0FF? file0x000 to file0x254 doesn't look hexadecimal...

    – xenoid
    16 hours ago
















1















I know that I can download a sequence of files using decimal numbers in curl:



curl site.com/file[000-100].jpg -o "file#.jpg"


But I need to download a hexadecimal series of files named file0x000 to file0x254. Can I specify this in one command line? Or can someone help me with a bash script?










share|improve this question









New contributor




Alan in Oakland is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
















  • 1





    Did you mean file0x000 to file0x0FF? file0x000 to file0x254 doesn't look hexadecimal...

    – xenoid
    16 hours ago














1












1








1








I know that I can download a sequence of files using decimal numbers in curl:



curl site.com/file[000-100].jpg -o "file#.jpg"


But I need to download a hexadecimal series of files named file0x000 to file0x254. Can I specify this in one command line? Or can someone help me with a bash script?










share|improve this question









New contributor




Alan in Oakland is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












I know that I can download a sequence of files using decimal numbers in curl:



curl site.com/file[000-100].jpg -o "file#.jpg"


But I need to download a hexadecimal series of files named file0x000 to file0x254. Can I specify this in one command line? Or can someone help me with a bash script?







bash bash-scripting curl






share|improve this question









New contributor




Alan in Oakland is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




Alan in Oakland is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited 18 hours ago









JakeGould

31.6k1097139




31.6k1097139






New contributor




Alan in Oakland is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked 18 hours ago









Alan in OaklandAlan in Oakland

62




62




New contributor




Alan in Oakland is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





Alan in Oakland is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






Alan in Oakland is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.








  • 1





    Did you mean file0x000 to file0x0FF? file0x000 to file0x254 doesn't look hexadecimal...

    – xenoid
    16 hours ago














  • 1





    Did you mean file0x000 to file0x0FF? file0x000 to file0x254 doesn't look hexadecimal...

    – xenoid
    16 hours ago








1




1





Did you mean file0x000 to file0x0FF? file0x000 to file0x254 doesn't look hexadecimal...

– xenoid
16 hours ago





Did you mean file0x000 to file0x0FF? file0x000 to file0x254 doesn't look hexadecimal...

– xenoid
16 hours ago










1 Answer
1






active

oldest

votes


















0














Just put the curl in an for iterator loop like this; save this file as some name—like test.sh and make sure that is has executable permissions—then run that file as ./test.sh:



#!/bin/bash

for i in {0..254}; do
filename=$(printf file0x%03d.jpg $i);
echo curl site.com/${filename} -o "${filename}";
done


The above works for me in macOS Mojave (10.14.3) as well as RedHat 7 and Ubuntu 16.04. But the following is slightly simpler, but will only work correctly on RedHat and Ubuntu; on macOS there are no padded numbers:



#!/bin/bash

for i in {000..254}; do
curl site.com/file0x$i.jpg -o file0x$i.jpg;
done





share|improve this answer


























  • Thank you, Jake

    – Alan in Oakland
    17 hours ago











  • @AlaninOakland You’re welcome! If this answer has helped you, please be sure to upvote it. And if it is the answer that has indeed answered your question, please be sure to check it off as such.

    – JakeGould
    17 hours ago











  • I think you mean file0x%03x.jpg and not file0x%03d.jpg. Otherwise the printf isn't necessary since you can generate the left-padded numbers with brace expansion using {000..254}.

    – xenoid
    16 hours ago













  • I believe the original poster made a mistake when asking about hexadecimal and truly means file0x000 to file0x254; so d is appropriate. Regarding using brace expansion using {000..254} how exactly would that work in a per number Curl call like this?

    – JakeGould
    16 hours ago






  • 1





    @JakeGould for i in {000..254} ; do curl site.com/file0x$i.jpg -o file0x$i.jpg ; done

    – xenoid
    10 hours ago











Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "3"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});






Alan in Oakland is a new contributor. Be nice, and check out our Code of Conduct.










draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1411272%2fhow-do-i-use-a-hexadecimal-range-when-downloading-multiple-files-in-curl%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














Just put the curl in an for iterator loop like this; save this file as some name—like test.sh and make sure that is has executable permissions—then run that file as ./test.sh:



#!/bin/bash

for i in {0..254}; do
filename=$(printf file0x%03d.jpg $i);
echo curl site.com/${filename} -o "${filename}";
done


The above works for me in macOS Mojave (10.14.3) as well as RedHat 7 and Ubuntu 16.04. But the following is slightly simpler, but will only work correctly on RedHat and Ubuntu; on macOS there are no padded numbers:



#!/bin/bash

for i in {000..254}; do
curl site.com/file0x$i.jpg -o file0x$i.jpg;
done





share|improve this answer


























  • Thank you, Jake

    – Alan in Oakland
    17 hours ago











  • @AlaninOakland You’re welcome! If this answer has helped you, please be sure to upvote it. And if it is the answer that has indeed answered your question, please be sure to check it off as such.

    – JakeGould
    17 hours ago











  • I think you mean file0x%03x.jpg and not file0x%03d.jpg. Otherwise the printf isn't necessary since you can generate the left-padded numbers with brace expansion using {000..254}.

    – xenoid
    16 hours ago













  • I believe the original poster made a mistake when asking about hexadecimal and truly means file0x000 to file0x254; so d is appropriate. Regarding using brace expansion using {000..254} how exactly would that work in a per number Curl call like this?

    – JakeGould
    16 hours ago






  • 1





    @JakeGould for i in {000..254} ; do curl site.com/file0x$i.jpg -o file0x$i.jpg ; done

    – xenoid
    10 hours ago
















0














Just put the curl in an for iterator loop like this; save this file as some name—like test.sh and make sure that is has executable permissions—then run that file as ./test.sh:



#!/bin/bash

for i in {0..254}; do
filename=$(printf file0x%03d.jpg $i);
echo curl site.com/${filename} -o "${filename}";
done


The above works for me in macOS Mojave (10.14.3) as well as RedHat 7 and Ubuntu 16.04. But the following is slightly simpler, but will only work correctly on RedHat and Ubuntu; on macOS there are no padded numbers:



#!/bin/bash

for i in {000..254}; do
curl site.com/file0x$i.jpg -o file0x$i.jpg;
done





share|improve this answer


























  • Thank you, Jake

    – Alan in Oakland
    17 hours ago











  • @AlaninOakland You’re welcome! If this answer has helped you, please be sure to upvote it. And if it is the answer that has indeed answered your question, please be sure to check it off as such.

    – JakeGould
    17 hours ago











  • I think you mean file0x%03x.jpg and not file0x%03d.jpg. Otherwise the printf isn't necessary since you can generate the left-padded numbers with brace expansion using {000..254}.

    – xenoid
    16 hours ago













  • I believe the original poster made a mistake when asking about hexadecimal and truly means file0x000 to file0x254; so d is appropriate. Regarding using brace expansion using {000..254} how exactly would that work in a per number Curl call like this?

    – JakeGould
    16 hours ago






  • 1





    @JakeGould for i in {000..254} ; do curl site.com/file0x$i.jpg -o file0x$i.jpg ; done

    – xenoid
    10 hours ago














0












0








0







Just put the curl in an for iterator loop like this; save this file as some name—like test.sh and make sure that is has executable permissions—then run that file as ./test.sh:



#!/bin/bash

for i in {0..254}; do
filename=$(printf file0x%03d.jpg $i);
echo curl site.com/${filename} -o "${filename}";
done


The above works for me in macOS Mojave (10.14.3) as well as RedHat 7 and Ubuntu 16.04. But the following is slightly simpler, but will only work correctly on RedHat and Ubuntu; on macOS there are no padded numbers:



#!/bin/bash

for i in {000..254}; do
curl site.com/file0x$i.jpg -o file0x$i.jpg;
done





share|improve this answer















Just put the curl in an for iterator loop like this; save this file as some name—like test.sh and make sure that is has executable permissions—then run that file as ./test.sh:



#!/bin/bash

for i in {0..254}; do
filename=$(printf file0x%03d.jpg $i);
echo curl site.com/${filename} -o "${filename}";
done


The above works for me in macOS Mojave (10.14.3) as well as RedHat 7 and Ubuntu 16.04. But the following is slightly simpler, but will only work correctly on RedHat and Ubuntu; on macOS there are no padded numbers:



#!/bin/bash

for i in {000..254}; do
curl site.com/file0x$i.jpg -o file0x$i.jpg;
done






share|improve this answer














share|improve this answer



share|improve this answer








edited 2 hours ago

























answered 18 hours ago









JakeGouldJakeGould

31.6k1097139




31.6k1097139













  • Thank you, Jake

    – Alan in Oakland
    17 hours ago











  • @AlaninOakland You’re welcome! If this answer has helped you, please be sure to upvote it. And if it is the answer that has indeed answered your question, please be sure to check it off as such.

    – JakeGould
    17 hours ago











  • I think you mean file0x%03x.jpg and not file0x%03d.jpg. Otherwise the printf isn't necessary since you can generate the left-padded numbers with brace expansion using {000..254}.

    – xenoid
    16 hours ago













  • I believe the original poster made a mistake when asking about hexadecimal and truly means file0x000 to file0x254; so d is appropriate. Regarding using brace expansion using {000..254} how exactly would that work in a per number Curl call like this?

    – JakeGould
    16 hours ago






  • 1





    @JakeGould for i in {000..254} ; do curl site.com/file0x$i.jpg -o file0x$i.jpg ; done

    – xenoid
    10 hours ago



















  • Thank you, Jake

    – Alan in Oakland
    17 hours ago











  • @AlaninOakland You’re welcome! If this answer has helped you, please be sure to upvote it. And if it is the answer that has indeed answered your question, please be sure to check it off as such.

    – JakeGould
    17 hours ago











  • I think you mean file0x%03x.jpg and not file0x%03d.jpg. Otherwise the printf isn't necessary since you can generate the left-padded numbers with brace expansion using {000..254}.

    – xenoid
    16 hours ago













  • I believe the original poster made a mistake when asking about hexadecimal and truly means file0x000 to file0x254; so d is appropriate. Regarding using brace expansion using {000..254} how exactly would that work in a per number Curl call like this?

    – JakeGould
    16 hours ago






  • 1





    @JakeGould for i in {000..254} ; do curl site.com/file0x$i.jpg -o file0x$i.jpg ; done

    – xenoid
    10 hours ago

















Thank you, Jake

– Alan in Oakland
17 hours ago





Thank you, Jake

– Alan in Oakland
17 hours ago













@AlaninOakland You’re welcome! If this answer has helped you, please be sure to upvote it. And if it is the answer that has indeed answered your question, please be sure to check it off as such.

– JakeGould
17 hours ago





@AlaninOakland You’re welcome! If this answer has helped you, please be sure to upvote it. And if it is the answer that has indeed answered your question, please be sure to check it off as such.

– JakeGould
17 hours ago













I think you mean file0x%03x.jpg and not file0x%03d.jpg. Otherwise the printf isn't necessary since you can generate the left-padded numbers with brace expansion using {000..254}.

– xenoid
16 hours ago







I think you mean file0x%03x.jpg and not file0x%03d.jpg. Otherwise the printf isn't necessary since you can generate the left-padded numbers with brace expansion using {000..254}.

– xenoid
16 hours ago















I believe the original poster made a mistake when asking about hexadecimal and truly means file0x000 to file0x254; so d is appropriate. Regarding using brace expansion using {000..254} how exactly would that work in a per number Curl call like this?

– JakeGould
16 hours ago





I believe the original poster made a mistake when asking about hexadecimal and truly means file0x000 to file0x254; so d is appropriate. Regarding using brace expansion using {000..254} how exactly would that work in a per number Curl call like this?

– JakeGould
16 hours ago




1




1





@JakeGould for i in {000..254} ; do curl site.com/file0x$i.jpg -o file0x$i.jpg ; done

– xenoid
10 hours ago





@JakeGould for i in {000..254} ; do curl site.com/file0x$i.jpg -o file0x$i.jpg ; done

– xenoid
10 hours ago










Alan in Oakland is a new contributor. Be nice, and check out our Code of Conduct.










draft saved

draft discarded


















Alan in Oakland is a new contributor. Be nice, and check out our Code of Conduct.













Alan in Oakland is a new contributor. Be nice, and check out our Code of Conduct.












Alan in Oakland is a new contributor. Be nice, and check out our Code of Conduct.
















Thanks for contributing an answer to Super User!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1411272%2fhow-do-i-use-a-hexadecimal-range-when-downloading-multiple-files-in-curl%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Cannot install PyQt5 The Next CEO of Stack OverflowCannot install tcpreplay 3.4.4cannot...

Kapp-Putsch Acontecimentos | Outros artigos | Menu de navegação

Why did early computer designers eschew integers? The Next CEO of Stack OverflowWhat register...