Download File Using curl Here, the “-O” flag tells curl to download and save the file in the current directory. To download and save the file with a different file name, use the “-o” flag. With this flag, the file will be downloaded and saved at the current working directory.
This is where your file will be saved if simply enter :w filename . You can change the working directory with :cd path/to/new/directory . Or you can enter the full path to the location where you want to save the file with the write command, e.g., :w /var/www/filename .
When using Curl, you must explicitly request that the downloaded resource be saved to disk by using the --output (-o) or --remote-name (-O) command-line options. The file will be saved to the current directory that you are working in.
I don't think you can give a path to curl, but you can CD to the location, download and CD back.
cd target/path && { curl -O URL ; cd -; }
Or using subshell.
(cd target/path && curl -O URL)
Both ways will only download if path exists. -O
keeps remote file name. After download it will return to original location.
If you need to set filename explicitly, you can use small -o
option:
curl -o target/path/filename URL
This option comes in curl 7.73.0:
curl --create-dirs -O --output-dir /tmp/receipes https://example.com/pancakes.jpg
curl
doesn't have an option to that (without also specifying the filename), but wget
does. The directory can be relative or absolute. Also, the directory will automatically be created if it doesn't exist.
wget -P relative/dir "$url"
wget -P /absolute/dir "$url"
For powershell in Windows, you can add relative path + filename to --output
flag:
curl -L http://github.com/GorvGoyl/Notion-Boost-browser-extension/archive/master.zip --output build_firefox/master-repo.zip
here build_firefox is relative folder.
it works for me:
curl http://centos.mirror.constant.com/8-stream/isos/aarch64/CentOS-Stream-8-aarch64-20210916-boot.iso --output ~/Downloads/centos.iso
where:
--output
allows me to set up the path and the naming of the file and extension file that I want to place.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With