wget command to download a file and save as a different filename

I am downloading a file using the wget command. But when it downloads to my local machine, I want it to be saved as a different filename.

For example: I am downloading a file from www.examplesite.com/textfile.txt

I want to use wget to save the file textfile.txt on my local directory as newfile.txt . I am using the wget command as follows:

wget www.examplesite.com/textfile.txt

Use the -O file option.

Eg

wget google.com
...
16:07:52 (538.47 MB/s) - `index.html' saved [10728]

vs.

wget -O foo.html google.com
...
16:08:00 (1.57 MB/s) - `foo.html' saved [10728]

Also notice the order of parameters on the command line. At least on my Linux (CentOS 6):

wget -O FILE URL

works. But:

wget URL -O FILE

won't give you the right output filename.


You would use the command Mechanical snail listed. Notice the uppercase O. Full command line to use could be:

wget www.examplesite.com/textfile.txt --output-document=newfile.txt

or

wget www.examplesite.com/textfile.txt -O newfile.txt

Hope that helps.

链接地址: http://www.djcxy.com/p/57160.html

上一篇: 防止wget递归到排除的目录中

下一篇: wget命令下载文件并保存为不同的文件名