Skip Directory Downloading with Wget in Linux
Wget is a powerful command-line tool used for downloading files over the internet in Linux. It supports various options that allow users to customize their downloads. One common use case is downloading a website or a specific directory from a website. However, sometimes you might want to skip downloading certain directories while downloading a website or a directory.
The Problem: Downloading a Specific Directory with Wget
Suppose you want to download the /things/summer/tables/books/directory directory from the website sssssssssss.com. You can use the following command:
wget -r -np -nd --no-parent sssssssssss.com/things/summer/tables/books/directory
This command uses the following options:
-r: recursive download-np: no parent, i.e., don't go up to the parent directory-nd: no directories, i.e., don't create any directories when downloading--no-parent: don't go up to the parent directory when downloading
However, this command will download the entire directory, including all its subdirectories and files. What if you want to skip downloading a specific subdirectory, say /sport?
The Solution: Skip Directory Downloading with Wget
Wget provides an option called --reject-regex that allows you to skip downloading files or directories that match a regular expression. You can use this option to skip downloading the /sport directory as follows:
wget -r -np -nd --no-parent --reject-regex '.*sport.*' sssssssssss.com/things/summer/tables/books/directory
This command will download all files and directories in the /things/summer/tables/books/directory directory, except those that match the regular expression .*sport.*. The regular expression .* matches any string, and the sport part matches the name of the directory you want to skip. The .* before and after sport ensures that the regular expression matches any directory or file name that contains the string sport.
Wget is a powerful command-line tool for downloading files and directories in Linux. With the --reject-regex option, you can skip downloading specific directories or files that match a regular expression. This can be useful when you want to download a specific directory from a website, but want to exclude certain subdirectories or files.
- Wget is a command-line tool for downloading files and directories in Linux
- The
--reject-regexoption allows you to skip downloading files or directories that match a regular expression - You can use the
--reject-regexoption to skip downloading specific subdirectories or files when downloading a directory from a website