*curl: (3) URL rejected: Malformed input to a URL function* #8

Open
opened 2026-01-07 18:16:05 +01:00 by Benjamin_Loison · 1 comment

On my Linux Mint 22.2 Cinnamon Framework 13:

Bash script:
(
    curl https://www.wikidata.org/w/rest.php/wikibase/v1/entities/items/Q42/statements \ 
        -H 'Authorization: Bearer TEST'
) | sed -n 's/\(.\{25\}\).*\(.\{25\}\)/\1...\2/p'
Output:
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  163k    0  163k    0     0   113k      0 --:--:--  0:00:01 --:--:--  113k
curl: (3) URL rejected: Malformed input to a URL function
-H: command not found
{"P31":[{"id":"Q42$F078E5...","content":"Q159288"}}]}

Note:

-H: command not found

do not have this issue if remove the newline.

DuckDuckGo and Google search Linux get first and last n characters and Linux cut from the end.

echo 0123456789 | cut -c 3- | rev | cut -c 3- | rev
234567

The Unix Stack Exchange answer 723446

echo 0123456789 | sed -n 's/\(.\{3\}\).*\(.\{3\}\)/\1...\2/p'
012...789

parentheses are necessary.

DuckDuckGo search sed p.

The Stack Overflow answer 20194559 helps to some extent precising what p stands for.

On my Linux Mint 22.2 Cinnamon Framework 13: <details> <summary>Bash script:</summary> ```bash ( curl https://www.wikidata.org/w/rest.php/wikibase/v1/entities/items/Q42/statements \ -H 'Authorization: Bearer TEST' ) | sed -n 's/\(.\{25\}\).*\(.\{25\}\)/\1...\2/p' ``` </details> <details> <summary>Output:</summary> ``` % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 163k 0 163k 0 0 113k 0 --:--:-- 0:00:01 --:--:-- 113k curl: (3) URL rejected: Malformed input to a URL function -H: command not found {"P31":[{"id":"Q42$F078E5...","content":"Q159288"}}]} ``` </details> Note: ``` -H: command not found ``` do not have this issue if remove the newline. DuckDuckGo and Google search *Linux get first and last n characters* and *Linux cut from the end*. ```bash echo 0123456789 | cut -c 3- | rev | cut -c 3- | rev ``` ``` 234567 ``` [The Unix Stack Exchange answer 723446](https://unix.stackexchange.com/a/723446) ```bash echo 0123456789 | sed -n 's/\(.\{3\}\).*\(.\{3\}\)/\1...\2/p' ``` ``` 012...789 ``` parentheses are necessary. DuckDuckGo search *sed p*. [The Stack Overflow answer 20194559](https://stackoverflow.com/a/20194559) helps to some extent precising what `p` stands for.
Author
Owner
Related to [Improve_websites_thanks_to_open_source/issues/3012](https://codeberg.org/Benjamin_Loison/Improve_websites_thanks_to_open_source/issues/3012).
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Benjamin_Loison/curl#8