Menu
Coddy logo textTech

Saving Responses

Lesson 27 of 47 in Coddy's Networking with the Terminal course.

Printing a response to the screen is fine for a line of text and useless for a file. -o saves the body to a name you choose:

curl -s -o page.html http://127.0.0.1:9117/index.html

There is also -O, capital, which keeps the remote file's own name. Handy, and worth being careful with, since the server chooses what lands in your folder.

The other use is deliberately throwing the body away. -o /dev/null sends it nowhere, which is exactly what you want when you only care about the status code or the timing. You have been using that already.

Once a response is a file, ordinary terminal tools apply: wc -c to count bytes, grep to search it, head to peek.

challenge icon

Challenge

Medium

Download to a file, then measure the file.

  1. Create index.html containing saved to disk
  2. Serve the folder on port 9117
  3. Fetch it, saving the body as copy.html
  4. Print the byte count of copy.html

The text is 13 characters plus a newline, so the output is:

14

Try it yourself

Terminal
quiz iconTest yourself

This lesson includes a short quiz. Start the lesson to answer it and track your progress.

All lessons in Networking with the Terminal

Practice on your own: Terminal playground