Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to get curl, using a script, to download a file and save it to a certain directory. I got it to download but I dont know how to get it to a certain directory from a script. It usually just saves it to the current working directory.

share|improve this question

closed as off-topic by Jenny D, Chris S May 2 '14 at 13:05

  • This question does not appear to be about server, networking, or related infrastructure administration within the scope defined in the help center.
If this question can be reworded to fit the rules in the help center, please edit the question.

This question appears to be off-topic because it is about a typical User use-case, not directly related to System Administration. Questions like this should be asked on Unix & Linux. This question is too old to migrate there. – Chris S May 2 '14 at 13:05
up vote 9 down vote accepted
curl > /path/to/dir/index.html
share|improve this answer


You can use

-o, --output FILE Write output to instead of stdout

curl --url --output /any/file-location

share|improve this answer
This doesn't answer the question. – Andrew Schulman May 2 '14 at 10:51

Let curl and the shell each do what they do well:

(cd TARGET_DIRECTORY && curl ...)

Also there may be things that interest you in the description of the -o option in the manual.

share|improve this answer