Curl Cheatsheet

get website header responses

curl -I

Find a string

To search for a specific string within the website content, you can pipe the output of curl to grep. grep is a command-line tool used for searching text patterns. For example, to search for the string “example” in the website content, you can use:

curl | grep "example"

By default, grep is case-sensitive. If you want to perform a case-insensitive search, you can use the -i flag like this:

curl | grep -i "example"

If you want to extract more specific information or format the output differently, you can use awk for more advanced text processing. For instance, to extract and print the lines containing the word “example” along with line numbers, you can use:

curl | awk '/example/{print NR, $0}'

Check URL redirect is working

You can use this to check if http is redirecting to https. Or any other redirect. The response will contain the end point url.

  • The location header in the response should be the https version.
  • The status code should be 301 or 302
curl -I

Bypass the cache

curl -I -H "Cache-Control: no-cache"
This post is licensed under CC BY 4.0 by the author.

Comments powered by Disqus.