How to change filename of a file downloaded with wget?
When using wget to download files, you may often encounter situations where you need to change the filename of the downloaded file. wget provides a convenient parameter (capital O, representing Output), which allows users to specify the filename for the downloaded file.Using the Parameter to Change the FilenameSuppose you want to download a PDF file from a URL, where the original filename is , but you wish to save it as . You can use the following command:This command instructs wget to download the file from the specified URL and use the parameter to specify the filename for the downloaded file as .Practical Application ExampleFor instance, if you need to automate downloading daily reports in your work, and the report URL is fixed, but you need to name the report based on the download date, you can combine it with date functions in shell scripting:This command uses the current date (e.g., ) to form the filename, saving the downloaded PDF report as .Important NotesEnsure that when using the parameter, the specified filename includes the correct file extension (e.g., , ), which is crucial for subsequent use of the file.If the specified filename already exists, wget will overwrite the file unless other wget parameters are used to prevent this.Using the parameter is a straightforward and effective method to control the naming of files downloaded with wget, making it highly suitable for scenarios requiring custom naming of downloaded files.