From 152b2e289181abd97d0fd233f7ef0ade58fe8605 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Mon, 30 Dec 2024 14:54:21 +0100 Subject: [PATCH] cmdline/variables.md: the syntax is tweaked Closes #530 --- cmdline/variables.md | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/cmdline/variables.md b/cmdline/variables.md index 18332a368..4b6df4698 100644 --- a/cmdline/variables.md +++ b/cmdline/variables.md @@ -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