Many modern URLs use shorteners or redirects (HTTP 301/302). By default, curl won't follow them. Use the -L (location) flag to ensure you reach the final file. curl -L -O https://bit.ly Use code with caution. 3. Resuming Interrupted Downloads
The most fundamental way to use curl is to provide a URL. By default, curl outputs the file content directly to your terminal (stdout). To save it as a file, you need to use specific flags. Using -o (Lowercase: Custom Filename) If you want to save the file with a specific name: curl -o my_document.pdf https://example.com Use code with caution. Using -O (Uppercase: Remote Filename) If you want to keep the original filename from the server: curl -O https://example.com Use code with caution. 2. Handling Redirects with -L download file with curl
If you're on a shared network and don't want to hog all the bandwidth, you can "throttle" the download speed using --limit-rate . Many modern URLs use shorteners or redirects (HTTP 301/302)
If you are downloading a massive file and your connection drops, don't start over. Use the -C - flag to resume where you left off. curl -C - -O https://example.com Use code with caution. 4. Downloading Multiple Files curl is incredibly efficient at batching requests. curl -O URL1 -O URL2 Use code with caution. Use Ranges: Download image1.jpg through image10.jpg : curl -O https://example.com[1-10].jpg Use code with caution. 5. Managing Speed and Bandwidth curl -L -O https://bit