Back in September 2023, we extended the curl command line tool with a brand-new relatively innovative and versatile variable system. Utilizing this, users can utilize files, environment variables and more in an effective method when constructing curl command lines in methods not formerly possible– with nearly all existing command line choices.
curl command lines were currently rather capable before this, however these brand-new variables definitely took it up a number of extra notches.
Come February 2025
In the pending curl 8.12.0 release, we extend this variable assistance a little more. Beginning now, you can designate a variable to hold the contents of a partial file. Get a byte variety from an offered file into a variable and utilize that variable in the command line, rather of utilizing the whole file.
You can get the very first couple of bytes and utilize as a username, you can get a hundred bytes in the middle of a file and POST that or do numerous other things.
Byte variety
You ask curl to check out a byte variety from a file rather of the entire one by adding [n-M] to the variable name, when you designate a variable. Where N and M are the very first and the last byte offsets into the file, 0 being the very first byte. If you leave out the 2nd number, it implies till completion of file.
Get the very first 32 bytes from a file called secret and set as password for daniel:
curl– variable “pwd[0-31]@secret”
— expand-user daniel:
https://example.com/
Avoid the very first thousand bytes from a file called localfile and send out the rest of it in a POST:
curl– variable “upload[1000-]@localfile”
— expand-post’ upload’
https://example.com/ With functions
You can naturally likewise integrate the byte offsets with the basic broaden functionsGet the very first hundred bytes from the file called random and send them base64 encoded in a POST:
curl– variable “binary[0-99]@random”
— expand-post’ binary: b64′
https://example.com/
I hope you will like it.
Update
After his post was very first released, we went over the precise syntax for this function and chose to fine-tune it a little to make it less most likely that old curl variations might be fooled when attempting a brand-new command line alternatives.
This variation is now revealing the upgraded syntax.
Post navigation curl, open source and networking ยป …
Find out more