• Skip to secondary menu
  • Skip to main content
  • Skip to primary sidebar

Python and R Tips

Learn Data Science with Python and R

  • Home
  • Python
  • Pandas
    • Pandas 101
  • tidyverse
    • tidyverse 101
  • R
  • Linux
  • Conferences
  • Python Books
  • About
    • Privacy Policy
You are here: Home / Linux Tips / How to Download a File or Directory Using wget?

How to Download a File or Directory Using wget?

August 17, 2011 by cmdlinetips

If you are spending too much time on a terminal, there is a good chance that you would like to download a file or a directory from the web, but without really using a browser. You can use the command line utility “wget” to download a file or a directory right from your terminal.

The beauty of wget is that its is non-interactive, meaning that wget can quitely work in the background. wget manual explains that the non-interactive wget “allows you to start a retrieval and disconnect from the system, and wget gets the job done”.

How to Use wget to download a file from website?

To download a file using wget, just use wget with the web address of the file name. For example

wget http://www.google.com/doodle4google/history.html

will fetch you the history.html file from Google’s doodle4google directory. While fetching the file you will see whet printing the following things on your screen

–2011-08-17 15:52:28– http://www.google.com/doodle4google/history.html
Resolving www.google.com… 74.125.113.103, 74.125.113.104, 74.125.113.105, …
Connecting to www.google.com|74.125.113.103|:80… connected.
HTTP request sent, awaiting response… 200 OK
Length: unspecified
Saving to: `history.html.1′

[ <=> ] 9,889 –.-K/s in 0.02s

2011-08-17 15:52:28 (480 KB/s) – `history.html.1′ saved [9889]

How to Use wget to Download a file in the background?

Making wget to run in the background is very simple. Add “&” at the end of the command as follows.

wget  http://www.google.com/doodle4google/history.html &

How to Use wget to try multiple times to download a file?

Want to download a big file, but have a slower/unreliable internet connectivity? Don’t worry “wget” can easily handle that. You can specify the number of times wget should keep trying, in case it fails

wget ---tries 10 http://www.google.com/doodle4google/history.html &

–tries or -t option gives you an opportunity to specify the number of times you want to try to download.

How to use wget to download an entire directory from a website?

Perhaps, the utility wget is most useful in downloading an entire directory from the web.

wget -r http://path/to/the/directory

Share this:

  • Click to share on Facebook (Opens in new window) Facebook
  • Click to share on X (Opens in new window) X

Related posts:

Default ThumbnailTwo Most Useful Commands, If You Live On The Linux/MacOS Terminal Default ThumbnailHow to Make Vim More Colorful? Hint: Use Color Scheme Default ThumbnailHow to Find the List of Directories in a Directory in Linux/Mac OS X? Default ThumbnailBash tip: Search through history using the up and down arrows

Filed Under: Linux Tips, Uncategorized, wget, wget Download a Directory, wget Download a File Tagged With: Linux Tips, Mac Os X Tips, wget, wget download

Primary Sidebar

Subscribe to Python and R Tips and Learn Data Science

Learn Pandas in Python and Tidyverse in R

Tags

Altair Basic NumPy Book Review Data Science Data Science Books Data Science Resources Data Science Roundup Data Visualization Dimensionality Reduction Dropbox Dropbox Free Space Dropbox Tips Emacs Emacs Tips ggplot2 Linux Commands Linux Tips Mac Os X Tips Maximum Likelihood Estimation in R MLE in R NumPy Pandas Pandas 101 Pandas Dataframe Pandas Data Frame pandas groupby() Pandas select columns Pandas select_dtypes Python Python 3 Python Boxplot Python Tips R rstats R Tips Seaborn Seaborn Boxplot Seaborn Catplot Shell Scripting Sparse Matrix in Python tidy evaluation tidyverse tidyverse 101 Vim Vim Tips

RSS RSS

  • How to convert row names to a column in Pandas
  • How to resize an image with PyTorch
  • Fashion-MNIST data from PyTorch
  • Pandas case_when() with multiple examples
  • An Introduction to Statistical Learning: with Applications in Python Is Here
  • 10 Tips to customize ggplot2 title text
  • 8 Plot types with Matplotlib in Python
  • PCA on S&P 500 Stock Return Data
  • Linear Regression with Matrix Decomposition Methods
  • Numpy’s random choice() function

Copyright © 2025 · Lifestyle Pro on Genesis Framework · WordPress · Log in

Go to mobile version