• Home
  • Category: Bash

Getting the correct filename from the server with wget

If you’ve used the GNU wget utility, you know that often when wget downloads files, it saves files with odd file names. Sometimes these are long garbled filenames or the name ‘download’.

To get wget to honour the correct filename from the server, the method is to use wget with the –content-disposition flag.

Eg:

wget https://github.com/i-MSCP/imscp/archive/1.1.11.tar.gz --content-disposition

Unfortunately, –content-disposition does not have an alias, and it becomes easily a chore, typing that repeatedly. Some people create an alias for wget and use:

alias wget='wget --content-disposition'

The more proper method is to set the option in the configuration file in your home directory:

#cat ~/.wgetrc
content-disposition = on

Now wget will download files to the correct name.