I need to use wget to download a file to the directory /var/cache/foobar/ (so, as an example, if I download stackexchange-site-list.txt, it’d be downloaded to /var/cache/foobar/stackexchange-site-list.txt)
Is this possible? curl would also be an option, but I’d prefer to not use curl, since it’s not installed by default.
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
wget -P /var/cache/foobar/ [...] wget --directory-prefix=/var/cache/foobar/ [...]
Method 2
If you know the name of the file ahead of time, you can use the -O option to wget to tell it where to write the file.
wget -O /var/cache/foobar/stackexchange-site-list.txt http://url.to/stackexchange-site-list.txt
Method 3
wget -e robots=off -r --no-parent /home/user/Desktop/MIT/ http://abc.tamu.edu/projects/tzivi/repository/revisions/2/raw/tzivi/
To add: The above code would allow you to download ALL files from the targeted directory to the directory of your choice in a single command.
Break Down of Command:
The Parameters for which wget uses to download the entire directory at once instead of one file at a time:
wget -e robots=off -r --no-parent
The Destination of Downloaded Files
/home/user/Desktop/MIT/
The Origin of Files (Online Directory)
http://abc.tamu.edu/projects/tzivi/repository/revisions/2/raw/tzivi/
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0