#curl
43 one-liners with this tag.
All one-liners tagged curl
Check Cache-Control of all CSS, JS and image files on a page
$curl -s https://example.com/ | grep -oE '(src|href)="[^"]+\.(css|js|woff2?|jpe?g|png|gif|webp|avif|svg)(\?[^"]*)?"' | cut -d'"' -f2 | sed -E 's#^//#https://#; s#^/#https://example.com/#' | grep '^http' | sort -u | while read -r a; do printf '%-45s %s\n' "$(curl -sI "$a" | grep -i '^cache-control:' | tr -d '\r')" "$a"; done
Check for soft 404s: does a missing page really return 404
$curl -s -o /dev/null -w '%{http_code} %{redirect_url}\n' https://example.com/diese-seite-gibt-es-nicht-$RANDOM
Check HTTP status codes for a list of URLs
$while read -r u; do printf '%s %s\n' "$(curl -o /dev/null -sS -w '%{http_code}' "$u")" "$u"; done < urls.txt
Check HTTP/3 support via the Alt-Svc header
$curl -sI https://example.com/ | grep -i '^alt-svc'
Check if LiteSpeed Cache serves a page from cache
$curl -s -o /dev/null -D - https://example.com/ | grep -iE "^(server|x-litespeed-cache[a-z-]*):"
Check maintenance mode for status 503 and Retry-After
$curl -s -o /dev/null -D - https://example.com/ | grep -iE '^(HTTP/|retry-after:)'
Check the browser caching headers of a file
$curl -sI https://example.com/wp-includes/css/dist/block-library/style.min.css | grep -iE "^(cache-control|expires|etag|last-modified|age):"
Check the status code of all sitemap.xml URLs in parallel
$curl -s https://example.com/sitemap.xml | grep -oP '(?<=<loc>)[^<]+' | xargs -P 8 -I{} curl -o /dev/null -s -w '%{http_code} %{url_effective}\n' {} | grep -v '^200 ' | sort
Check the X-Robots-Tag header of a URL
$curl -s -o /dev/null -D - https://example.com/ | grep -i '^x-robots-tag'
Check whether a website sends the HSTS header
$curl -sI https://example.com/ | grep -i "^strict-transport-security"
Check whether a website serves gzip or Brotli
$curl -s -o /dev/null -D - -H "Accept-Encoding: br, gzip" https://example.com/ | grep -i "^content-encoding"
Check whether a website supports HTTP/2
$curl -sI --http2 https://example.com/ | head -1
Check whether the server returns 304 Not Modified
$curl -s -o /dev/null -w '%{http_code}\n' -H "If-Modified-Since: $(curl -sI https://example.com/ | grep -i '^last-modified:' | cut -d' ' -f2- | tr -d '\r')" https://example.com/
Collect all URLs from a sitemap index
$curl -s https://example.com/sitemap_index.xml | grep -oP '(?<=<loc>)[^<]+' | xargs -n1 curl -s | grep -oP '(?<=<loc>)[^<]+' | sort -u
Compare the response time of a PHP page with a static file
$for u in https://example.com/ https://example.com/wp-includes/css/dist/block-library/style.min.css; do curl -o /dev/null -s -w "%{time_starttransfer}s TTFB $u\n" "$u"; done
Detect the web server and PHP version from HTTP headers
$curl -sI https://example.com/ | grep -iE "^(server|x-powered-by|via):"
Extract all URLs from a sitemap.xml
$curl -s https://example.com/sitemap.xml | grep -oP '(?<=<loc>)[^<]+' | sort -u
Extract and count the internal links of a page
$curl -s https://example.com/ | tr '\n' ' ' | grep -oiE 'href="[^"]+"' | sed -E 's/^href="//I; s/"$//; s/#.*//' | grep -E '^(/|https?://(www\.)?example.com)' | sort | uniq -c | sort -rn
Extract the H1 headings of a page
$curl -s https://example.com/ | tr '\n' ' ' | grep -oiP '<h1[^>]*>.*?</h1>' | sed -E 's/<[^>]+>//g; s/^\s+|\s+$//g'
Extract the structured data (JSON-LD) of a page
$curl -s https://example.com/ | tr '\n' ' ' | grep -oP '<script[^>]*application/ld\+json[^>]*>.*?</script>'
Fetch a page as Googlebot and compare with a normal request
$for ua in 'Mozilla/5.0 (X11; Linux x86_64)' 'Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)'; do curl -s -o /dev/null -A "$ua" -w "%{http_code} %{size_download} Bytes $ua\n" https://example.com/; done
Fetch robots.txt and show the Disallow rules
$curl -s https://example.com/robots.txt | grep -iE '^\s*(user-agent|disallow|allow|sitemap):'
Fetch the Apache server-status in compact form
$curl -s "http://localhost/server-status?auto"
Find images without a loading attribute on a page
$curl -s https://example.com/ | tr '\n' ' ' | grep -oiE '<img[^>]*>' | grep -vi 'loading='
Find images without an alt attribute on a page
$curl -s https://example.com/ | tr '\n' ' ' | grep -oiE '<img[^>]*>' | grep -viE '\balt='
Find meta robots and noindex in the HTML of a page
$curl -s https://example.com/ | tr '\n' ' ' | grep -oiE '<meta[^>]*name=.?(robots|googlebot)[^>]*>'
Find mixed content in the HTML of an HTTPS page
$curl -s https://example.com/ | tr '\n' ' ' | grep -oiE '(src|srcset|data-src)="http://[^"]+"|<link[^>]+href="http://[^"]+"|url\(.?http://[^)]+\)' | sort -u
Find scripts without async or defer on a page
$curl -s https://example.com/ | tr '\n' ' ' | grep -oiE '<script[^>]*src=[^>]*>' | grep -viE 'async|defer|type=.?module'
Find the public IP address of a server
$curl -4 -s https://icanhazip.com
Follow and show the redirect chain of a URL
$curl -sSIL http://example.com/ | grep -iE '^(HTTP/|location:)'
Get the latest WordPress version from the API
$curl -s https://api.wordpress.org/core/version-check/1.7/ | jq -r '.offers[0].version'
Measure gzip and Brotli savings for a URL
$for e in identity gzip br; do curl -s -o /dev/null -H "Accept-Encoding: $e" -w "$e: %{size_download} Bytes\n" https://example.com/; done
Measure HTTP load times and TTFB with curl
$curl -o /dev/null -sS -w 'DNS: %{time_namelookup}s Connect: %{time_connect}s TLS: %{time_appconnect}s TTFB: %{time_starttransfer}s Gesamt: %{time_total}s\n' https://example.com/
Measure the HTML and header size of a page
$curl -s -o /dev/null -w 'Status: %{http_code} Header: %{size_header} Bytes HTML: %{size_download} Bytes\n' https://example.com/
Measure TTFB repeatedly with minimum, median and maximum
$for i in $(seq 10); do curl -o /dev/null -s -w '%{time_starttransfer}\n' https://example.com/; done | LC_ALL=C sort -n | awk '{a[NR]=$1; s+=$1} END {printf "Min: %.3fs Median: %.3fs Max: %.3fs Schnitt: %.3fs\n", a[1], a[int((NR+1)/2)], a[NR], s/NR}'
Read the canonical tag of a page with curl
$curl -s https://example.com/ | tr '\n' ' ' | grep -oiE '<link[^>]*canonical[^>]*>'
Read the hreflang tags of a page
$curl -s https://example.com/ | tr '\n' ' ' | grep -oiE '<link[^>]*hreflang[^>]*>'
Read the title and meta description of a page with curl
$curl -s https://example.com/ | tr '\n' ' ' | grep -oiE '<title[^>]*>[^<]*</title>|<meta[^>]*name=.?description[^>]*>'
Show the HTTP response headers of a website
$curl -sSI https://example.com/
Show the number of redirects and the final URL
$curl -sL -o /dev/null -w 'Weiterleitungen: %{num_redirects}\nZiel: %{url_effective}\nStatus: %{http_code}\n' https://example.com/
Show the redirect chain of a URL with status codes
$curl -sIL "http://example.com/" | grep -iE "^(HTTP/|location:)"
Test a website on a new server before the DNS change
$curl -sSI --resolve example.com:443:203.0.113.10 https://example.com/
Test http, https, www and non-www at once
$for u in http://example.com/ http://www.example.com/ https://example.com/ https://www.example.com/; do curl -s -o /dev/null -m 10 -w "%{http_code} $u -> %{redirect_url}\n" "$u"; done