Skip to content

Commit

Permalink
cmdline/variables.md: the syntax is tweaked
Browse files Browse the repository at this point in the history
Closes #530
  • Loading branch information
bagder committed Dec 30, 2024
1 parent d2f4a4d commit 152b2e2
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions cmdline/variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,21 @@ You can assign the contents of a plain text file to a variable, too:

curl --variable varName@filename

Starting in curl 8.12.0, you can get a byte range from a given file by
appending `;[N-M]` to the file name, where `N` and `M` are numerical byte
offsets into the file where the second number can be omitted to mean until end
of file. For example, get the contents from a file from byte offset 100 to and
including byte offset 200:
Starting in curl 8.12.0, you can get a byte range from content by appending
`[N-M]` to the variable name, where `N` and `M` are numerical byte offsets
into the content where the second number can be omitted to mean until end of
data. For example, get the contents from a file from byte offset 100 to 199,
inclusive:

curl --variable "varName@filename;[100-200]"
curl --variable "varName[100-199]@filename"

Alternatively, get offset three to twelve from a plain text:

curl --variable "varName[3-12]=thefulltexttogetrangefrom"

Given a byte range that has no data results in an empty string. Asking for a
range that is larger than the content makes curl use the piece of the data
that exists.

## Expand

Expand Down

0 comments on commit 152b2e2

Please sign in to comment.