9 August 2025

Built-in curl patterns in Bash

by Romain Dehasseleer


Built-in curl patterns in Bash

Some common curl usages I keep reusing.


POST request with proxy

curl "https://auth.dehasseleer.be/auth4u/up" --proxy http://proxy.dehasseleer.be:9512 -X POST --data-raw "field-login=xxx&am-eai-password=yyyy"

GET request with cookies

curl "https://api.dehasseleer.be/v1/login" --proxy http://proxy.dehasseleer.be:9512 -X GET -b cookie.jar

Save response to variable

response=$(curl "https://api.dehasseleer.be/v1/login" --proxy http://proxy.dehasseleer.be:9512 -X GET -b cookies.jar)

Extract data from JSON (without jq)

token=$(echo "$response" | awk -F '[:,}]' '/"token"/ {gsub(/"/,"",$5);print $5}')

Call API with token

curl "https://api.dehasseleer.be/v1/profile/counter?token=$token" --proxy http://proxy.dehasseleer.be:9512 -X GET -b cookie.jar
tags: bash