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.
Asked
Active
Viewed 8.3k times
19
-
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.SE]. This question is too old to migrate there. – Chris S May 02 '14 at 13:05
-
1@ChrisS This doesn't make sense to me. System administrators constantly use curl and other tools to download to a specified directory. It is a fundamental part of system administration. – rjurney Nov 22 '19 at 22:38
3 Answers
10
CORRECTION:
You can use
-o, --output FILE Write output to instead of stdout
curl --url https://google.com --output /any/file-location

antonydenyer
- 209
- 2
- 5
-
3
-
2Documentation for -o says: >> The file will be saved in the current working directory. If you want the file saved in a different directory, make sure you change the current working directory before invoking curl with this option. – meglio Dec 01 '17 at 11:01
2
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.

Gilles 'SO- stop being evil'
- 9,391
- 1
- 33
- 48