linux中wget命令的常用参数
作者:互联网
1、-O , 指定下载文件的名称
示例:
[root@centos7pc1 test]# ls [root@centos7pc1 test]# wget -O xxx.zip https://s3.amazonaws.com/plink1-assets/plink_linux_x86_64_20220402.zip ## 指定下载内容为xxx.zip --2022-05-02 18:56:29-- https://s3.amazonaws.com/plink1-assets/plink_linux_x86_64_20220402.zip Resolving s3.amazonaws.com (s3.amazonaws.com)... 52.217.100.78 Connecting to s3.amazonaws.com (s3.amazonaws.com)|52.217.100.78|:443... connected. HTTP request sent, awaiting response... 200 OK Length: 8948563 (8.5M) [application/zip] Saving to: ‘xxx.zip’ 100%[===========================================================================================>] 8,948,563 2.30MB/s in 3.7s 2022-05-02 18:56:34 (2.30 MB/s) - ‘xxx.zip’ saved [8948563/8948563] [root@centos7pc1 test]# ls xxx.zip [root@centos7pc1 test]# unzip xxx.zip ## 正常解压 Archive: xxx.zip inflating: plink inflating: LICENSE inflating: toy.ped inflating: toy.map inflating: prettify [root@centos7pc1 test]# ls LICENSE plink prettify toy.map toy.ped xxx.zip
2、-P选项指定下载文件的目录:
示例:
[root@centos7pc1 test]# ls [root@centos7pc1 test]# ls /home/test2/ [root@centos7pc1 test]# wget -P /home/test2/ https://s3.amazonaws.com/plink1-assets/plink_linux_x86_64_20220402.zip ## -P选项指定下载目录 --2022-05-02 18:59:32-- https://s3.amazonaws.com/plink1-assets/plink_linux_x86_64_20220402.zip Resolving s3.amazonaws.com (s3.amazonaws.com)... 54.231.168.184 Connecting to s3.amazonaws.com (s3.amazonaws.com)|54.231.168.184|:443... connected. HTTP request sent, awaiting response... 200 OK Length: 8948563 (8.5M) [application/zip] Saving to: ‘/home/test2/plink_linux_x86_64_20220402.zip’ 100%[===========================================================================================>] 8,948,563 831KB/s in 23s 2022-05-02 18:59:56 (375 KB/s) - ‘/home/test2/plink_linux_x86_64_20220402.zip’ saved [8948563/8948563] [root@centos7pc1 test]# ls [root@centos7pc1 test]# ls /home/test2/ ## 查看 plink_linux_x86_64_20220402.zip
3、-b选项 后台下载
默认情况下,下载过程日志重定向到当前目录中的wget-log文件中,要查看下载状态,可以使用tail -f wget-log查看。
[root@centos7pc1 test]# wget -b https://s3.amazonaws.com/plink1-assets/plink_linux_x86_64_20220402.zip [root@centos7pc1 test]# ls plink_linux_x86_64_20220402.zip wget-log [root@centos7pc1 test]# tail wget-log 8400K .......... .......... .......... .......... .......... 96% 28.3M 0s 8450K .......... .......... .......... .......... .......... 97% 52.0M 0s 8500K .......... .......... .......... .......... .......... 97% 103M 0s 8550K .......... .......... .......... .......... .......... 98% 110M 0s 8600K .......... .......... .......... .......... .......... 98% 194K 0s 8650K .......... .......... .......... .......... .......... 99% 24.8M 0s 8700K .......... .......... .......... ........ 100% 60.1M=8.9s 2022-05-02 19:02:26 (977 KB/s) - ‘plink_linux_x86_64_20220402.zip’ saved [8948563/8948563]
4、-c选项 断点续传: 当我们下载一个大文件时,如果中途网络断开导致没有下载完成,我们就可以使用命令的-c选项恢复下载,让下载从断点续传,无需从头下载。
[root@centos7pc1 test]# wget -c https://s3.amazonaws.com/plink1-assets/plink_linux_x86_64_20220402.zip ## -c 断点续传 --2022-05-02 19:04:19-- https://s3.amazonaws.com/plink1-assets/plink_linux_x86_64_20220402.zip Resolving s3.amazonaws.com (s3.amazonaws.com)... 52.217.84.158 Connecting to s3.amazonaws.com (s3.amazonaws.com)|52.217.84.158|:443... connected. HTTP request sent, awaiting response... 200 OK Length: 8948563 (8.5M) [application/zip] Saving to: ‘plink_linux_x86_64_20220402.zip’ 100%[===========================================================================================>] 8,948,563 3.21MB/s in 2.7s 2022-05-02 19:04:23 (3.21 MB/s) - ‘plink_linux_x86_64_20220402.zip’ saved [8948563/8948563] [root@centos7pc1 test]# ls plink_linux_x86_64_20220402.zip
5、-i 选项:批量下载
[root@centos7pc1 test]# ls downlist.txt [root@centos7pc1 test]# cat downlist.txt ## 批量下载的文件列表 https://s3.amazonaws.com/plink1-assets/plink_linux_x86_64_20220402.zip https://yanglab.westlake.edu.cn/software/gcta/bin/gcta_v1.94.0Beta_linux_kernel_3_x86_64.zip [root@centos7pc1 test]# wget -i downlist.txt ## -i选项批量下载 --2022-05-02 19:08:13-- https://s3.amazonaws.com/plink1-assets/plink_linux_x86_64_20220402.zip Resolving s3.amazonaws.com (s3.amazonaws.com)... 52.217.90.206 Connecting to s3.amazonaws.com (s3.amazonaws.com)|52.217.90.206|:443... connected. HTTP request sent, awaiting response... 200 OK Length: 8948563 (8.5M) [application/zip] Saving to: ‘plink_linux_x86_64_20220402.zip’ 100%[===========================================================================================>] 8,948,563 741KB/s in 22s 2022-05-02 19:08:36 (399 KB/s) - ‘plink_linux_x86_64_20220402.zip’ saved [8948563/8948563] --2022-05-02 19:08:36-- https://yanglab.westlake.edu.cn/software/gcta/bin/gcta_v1.94.0Beta_linux_kernel_3_x86_64.zip Resolving yanglab.westlake.edu.cn (yanglab.westlake.edu.cn)... 42.247.30.142 Connecting to yanglab.westlake.edu.cn (yanglab.westlake.edu.cn)|42.247.30.142|:443... connected. HTTP request sent, awaiting response... 200 OK Length: 14274781 (14M) [application/zip] Saving to: ‘gcta_v1.94.0Beta_linux_kernel_3_x86_64.zip’ 100%[===========================================================================================>] 14,274,781 5.21MB/s in 2.6s 2022-05-02 19:08:39 (5.21 MB/s) - ‘gcta_v1.94.0Beta_linux_kernel_3_x86_64.zip’ saved [14274781/14274781] FINISHED --2022-05-02 19:08:39-- Total wall clock time: 26s Downloaded: 2 files, 22M in 25s (925 KB/s) [root@centos7pc1 test]# ls ## 查看下载结果 downlist.txt gcta_v1.94.0Beta_linux_kernel_3_x86_64.zip plink_linux_x86_64_20220402.zip
参考:https://baijiahao.baidu.com/s?id=1715589159640466321&wfr=spider&for=pc
标签:zip,参数,linux,wget,64,com,amazonaws,.......... 来源: https://www.cnblogs.com/liujiaxin2018/p/16216470.html