{"id":11314,"date":"2019-03-13T00:38:58","date_gmt":"2019-03-13T00:38:58","guid":{"rendered":"http:\/\/www.appservgrid.com\/paw92\/?p=11314"},"modified":"2019-03-13T00:38:58","modified_gmt":"2019-03-13T00:38:58","slug":"how-to-download-files-to-specific-directory-using-wget","status":"publish","type":"post","link":"https:\/\/www.appservgrid.com\/paw92\/index.php\/2019\/03\/13\/how-to-download-files-to-specific-directory-using-wget\/","title":{"rendered":"How to Download Files to Specific Directory Using Wget"},"content":{"rendered":"<p><a href=\"https:\/\/www.tecmint.com\/10-wget-command-examples-in-linux\/\" target=\"_blank\" rel=\"noopener\">Wget<\/a>\u00a0is a popular, non-interactive and widely used network downloader which supports protocols such as HTTP, HTTPS, and FTP, and retrieval via HTTP proxies. By default, wget downloads files in the current working directory where it is run.<\/p>\n<p><strong>Read Also<\/strong>:\u00a0<a href=\"https:\/\/www.tecmint.com\/rename-downloaded-file-with-wget-in-linux\/\" target=\"_blank\" rel=\"noopener\">How to Rename File While Downloading with Wget in Linux<\/a><\/p>\n<p>In this article, we will show how to download files to a specific directory without moving into that directory. This guide is useful, if, for example, you are using\u00a0<strong>wget<\/strong>\u00a0in a script, and want to automate downloads which should be stored in different directories.<\/p>\n<p>In addition,\u00a0<strong>wget<\/strong>\u00a0being non-interactive (can work in the background) by design makes it easy to use for automating downloads via shell scripts. You can actually initiate a download and disconnect from the system, letting wget complete the job.<\/p>\n<p>Wget\u2019s\u00a0<code>-P<\/code>\u00a0or\u00a0<code>--directory-prefix<\/code>\u00a0option is used to set the directory prefix where all retrieved files and subdirectories will be saved to.<\/p>\n<p>In this example, we will demonstrate how to download the\u00a0<a href=\"https:\/\/www.tecmint.com\/glances-an-advanced-real-time-system-monitoring-tool-for-linux\/\" target=\"_blank\" rel=\"noopener\">glances<\/a>\u00a0config template and store it under\u00a0<strong>\/etc\/glances\/<\/strong>\u00a0directory.<\/p>\n<pre>$ sudo mkdir \/etc\/glances\r\n$ ls \/etc\/glances\/\r\n$ sudo wget https:\/\/raw.githubusercontent.com\/nicolargo\/glances\/develop\/conf\/glances.conf -P \/etc\/glances\/\r\n$ ls \/etc\/glances\/\r\n<\/pre>\n<div id=\"attachment_30326\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/08\/Wget-Download-Files-to-Specific-Directory.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-30326\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/08\/Wget-Download-Files-to-Specific-Directory.png\" sizes=\"auto, (max-width: 857px) 100vw, 857px\" srcset=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/08\/Wget-Download-Files-to-Specific-Directory.png 857w, https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/08\/Wget-Download-Files-to-Specific-Directory-768x401.png 768w\" alt=\"Wget Download Files to Specific Directory\" width=\"857\" height=\"448\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">Wget Download Files to Specific Directory<\/p>\n<\/div>\n<p>If you are downloading a heavy file, you may want to add the\u00a0<code>-c<\/code>\u00a0or\u00a0<code>--continue<\/code>\u00a0flag, which means continue getting a partially-downloaded file. With it, you don\u2019t have to start the download afresh.<\/p>\n<p>This option helps you to resume downloading a file started by a previous instance of wget, or by another program or one that you had paused. It is also useful in case of any network failure. For example,<\/p>\n<pre>$ wget -c https:\/\/tenet.dl.sourceforge.net\/project\/parrotsecurity\/iso\/4.1\/Parrot-security-4.1_amd64.iso\r\n<\/pre>\n<p>For more information, see the\u00a0<strong>wget<\/strong>\u00a0man page.<\/p>\n<pre>$ man wget \r\n<\/pre>\n<p>You might also like to read these following related articles.<\/p>\n<ol>\n<li><a href=\"https:\/\/www.tecmint.com\/download-and-extract-tar-files-with-one-command\/\" target=\"_blank\" rel=\"noopener\">How to Download and Extract Tar Files with One Command<\/a><\/li>\n<li><a href=\"https:\/\/www.tecmint.com\/linux-command-line-tools-for-downloading-files\/\" target=\"_blank\" rel=\"noopener\">5 Linux Command Line Based Tools for Downloading Files and Browsing Websites<\/a><\/li>\n<li><a href=\"https:\/\/www.tecmint.com\/linux-curl-command-examples\/\" target=\"_blank\" rel=\"noopener\">15 Tips On How to Use \u2018Curl\u2019 Command in Linux<\/a><\/li>\n<\/ol>\n<p>That\u2019s all! In this short article, we have explained how to download files to a specific directory without moving into that directory, using wget. You can share your thoughts with us in the comments.<\/p>\n<p><a href=\"https:\/\/www.tecmint.com\/wget-download-file-to-specific-directory\/\" target=\"_blank\" rel=\"noopener\">Source<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Wget\u00a0is a popular, non-interactive and widely used network downloader which supports protocols such as HTTP, HTTPS, and FTP, and retrieval via HTTP proxies. By default, wget downloads files in the current working directory where it is run. Read Also:\u00a0How to Rename File While Downloading with Wget in Linux In this article, we will show how &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.appservgrid.com\/paw92\/index.php\/2019\/03\/13\/how-to-download-files-to-specific-directory-using-wget\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;How to Download Files to Specific Directory Using Wget&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-11314","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/11314","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/comments?post=11314"}],"version-history":[{"count":1,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/11314\/revisions"}],"predecessor-version":[{"id":11315,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/11314\/revisions\/11315"}],"wp:attachment":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/media?parent=11314"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/categories?post=11314"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/tags?post=11314"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}