All-in-one Collaborative API Development Platform

API Design

API Documentation

API Designing

API Mock

API Automated Testing

Sign up for free

Curl -o Command in Linux

Start for free
Home / Basic Knowledge / Curl -o Command in Linux

Curl -o Command in Linux

Curl is a linchpin for transferring data between local and remote systems. This post will provide a concise exploration of the "curl -o" command in Linux.

Curl is a linchpin for transferring data between local and remote systems. This post will provide a concise exploration of the "curl -o" command in Linux.

Apidog stands out for its visually engaging API response documentation and intuitive testing tools, featuring assertions and testing branches. For those prioritizing simplicity over intricate cURL commands, it offers an accessible and efficient solution.

curl -o command in Linux

There are many common cURL Commands with Examples, now we will introduce one of them.  The "curl -o" command in Linux is a powerful utility that plays a crucial role in retrieving files from the internet using the command-line tool, curl.

This command is particularly useful when you want to download a file from a remote server and save it with a specific name or location on your local machine. Let's delve into the details of what "curl -o" does and explore an example of its usage.

What does "curl -o" Do?

The "curl -o" command is used to download a file from a given URL and save it with a specified name or path on the local system. The "-o" flag in curl stands for "output," and it allows users to customize the destination of the downloaded file.

Example Usage:

Here's a simple example to illustrate how the "curl -o" command works:

curl -o myfile.zip https://example.com/myfile.zip

In this example:

  • curl is the command-line tool for making HTTP requests.
  • -o is the flag indicating that the next argument will be the output file.
  • myfile.zip is the name you want to give to the downloaded file.
  • https://example.com/myfile.zip is the URL of the file you want to download.

Executing this command will download the file from the specified URL and save it locally with the name "myfile.zip."

Advanced Features of "curl -o" Command in Linux

Let's explore some additional aspects and considerations related to the "curl -o" command:

Multiple URLs:

  • You can use "curl -o" with multiple URLs to download multiple files in a single command. For example:
curl -o file1.zip -o file2.zip https://example.com/file1.zip https://example.com/file2.zip
  • This command downloads both files and saves them with their respective names locally.

Resume Downloads:

  • The "-o" flag also allows you to resume interrupted downloads. If a download is interrupted, you can use the same "curl -o" command, and curl will automatically resume the download from where it left off.
  1. Wildcards:
  • You can use wildcards with the "-o" flag to download and save multiple files with similar names. For instance:
curl -o "files-[1-3].txt" https://example.com/files/[1-3].txt
  • This command downloads files-1.txt, files-2.txt, and files-3.txt and saves them with the specified names locally.

Output to Standard Output:

  • If you want to output the downloaded file to the standard output (stdout) instead of saving it to a file, you can use "-o -". This is useful when you want to process the file directly in the terminal without saving it to disk.
curl -o - https://example.com/myfile.txt

Overwriting Existing Files:

  • By default, "curl -o" will overwrite an existing file with the same name without prompting for confirmation. If you want to avoid overwriting, you can use the "-C -" flag, which will append data to the existing file without overwriting it.
curl -C - -o existing_file.txt https://example.com/existing_file.txt

Verbose Output:

  • For more detailed information during the download process, you can use the "-v" or "--verbose" flag with "curl -o" to display verbose output, including headers and progress information.
curl -o file.zip -v https://example.com/file.zip

These additional features provide greater flexibility and control when using the "curl -o" command for downloading files through the command line.


In essence, the "curl -o" command in Linux provides a convenient way to fetch files from the internet via the command line, offering flexibility in naming and storing the downloaded content.

Whether you are automating downloads or managing files in a script, understanding and utilizing the "curl -o" command proves invaluable in efficiently handling remote resources.