wget命令

Usage: wget [OPTION]... [URL]...

# 后台运行
-b, --background go to background after startup # log信息打印
-o, --output-file=FILE log messages to FILE
-a, --append-output=FILE append messages to FILE
-d, --debug print lots of debugging information
-q, --quiet quiet (no output) # url来源文件
-i, --input-file=FILE download URLs found in local or external FILE
-F, --force-html treat input file as HTML
-B, --base=URL resolves HTML input-file links (-i -F) # 下载回复
-O, --output-document=FILE write documents to FILE
-c, --continue resume getting a partially-downloaded file # 断电续传
--start-pos=OFFSET start downloading from zero-based position OFFSET
--progress=TYPE select progress gauge type
--show-progress display the progress bar in any verbosity mode -N, --timestamping don't re-retrieve files unless newer than local # 不下载早于的时间戳
--no-if-modified-since don't use conditional if-modified-since get requests in timestamping mode # 自从上次下载未进行修改
--no-use-server-timestamps don't set the local file's timestamp by the one on the server # 不使用服务器提供的时间戳 # 响应response
-S, --server-response print server response
--spider don't download anything # 下载速率设置...
-Q, --quota=NUMBER set retrieval quota to NUMBER # 设置递归层数
--bind-address=ADDRESS bind to ADDRESS (hostname or IP) on local host # 绑定ip访问,即以ip进行下载数据
--limit-rate=RATE limit download rate to RATE # 下载速率
--no-dns-cache disable caching DNS lookups # 不使用dns缓存,直接进行dns查询
--restrict-file-names=OS restrict chars in file names to ones OS allows # 使用系统所限制字符
--ignore-case ignore case when matching files/directories # 忽略大小写 # Http请求头设置
-E,
--header=STRING insert STRING among the headers
--compression=TYPE choose compression, one of auto, gzip and none. (default: none)
--max-redirect maximum redirections allowed per page # 最大次数进行重定向
--proxy-user=USER set USER as proxy username
--proxy-password=PASS set PASS as proxy password
--referer=URL include 'Referer: URL' header in HTTP request
--save-headers save the HTTP headers to file
-U, --user-agent=AGENT identify as AGENT instead of Wget/VERSION
--no-http-keep-alive disable HTTP keep-alive (persistent connections)
--no-cookies don't use cookies
--load-cookies=FILE load cookies from FILE before session
--save-cookies=FILE save cookies to FILE after session
--keep-session-cookies load and save session (non-permanent) cookies
--post-data=STRING use the POST method; send STRING as the data
--post-file=FILE use the POST method; send contents of FILE
--method=HTTPMethod use method "HTTPMethod" in the request
--body-data=STRING send STRING as data. --method MUST be set
--body-file=FILE send contents of FILE. --method MUST be set
--content-disposition honor the Content-Disposition header when
choosing local file names (EXPERIMENTAL)
--content-on-error output the received content on server errors
--auth-no-challenge send Basic HTTP authentication information
without first waiting for the server's
challenge

参考:linux下载命令

使用wget -Q限制总下载文件大小

当你想要下载的文件超过5M而退出下载,你可以使用以下命令:

wget -Q5m -i filelist.txt

注意:这个参数对单个文件下载不起作用,只能递归下载时才有效。

使用wget -r -A下载指定格式文件

可以在以下情况使用该功能

  • 下载一个网站的所有图片
  • 下载一个网站的所有视频
  • 下载一个网站的所有PDF文件

wget -p /path -A "*.png" url
wget -p /path -A png,jpg url

下载整个网站

你甚至可以用wget下载完整的站点, 然后进行离线浏览. 方法是使用如下命令:

wget --mirror --convert-links --page-requisites --no-parent -P /path/to/download https://example-domain.com

--mirror 会开启镜像所需要的所有选项.

--convert-links 会将所有链接转换成本地链接以便离线浏览.

--page-requisites 表示下载包括CSS样式文件,图片等所有所需的文件,以便离线时能正确地现实页面.

--no-parent 用于限制只下载网站的某一部分内容.

-P设置下载路径.

压缩与解压

tar

-c: 建立压缩档案

-x:解压

-t:查看内容

-r:向压缩归档文件末尾追加文件

-u:更新原压缩包中的文件

这五个是独立的命令,压缩解压都要用到其中一个,可以和别的命令连用但只能用其中一个。下面的参数是根据需要在压缩或解压档案时可选的。

-z:有gzip属性的

-j:有bz2属性的

-Z:有compress属性的

-v:显示所有过程

-O:将文件解开到标准输出

下面的参数-f是必须的

-f: 使用档案名字,切记,这个参数是最后一个参数,后面只能接档案名。

小节

  1. *.tar 用 tar –xvf 解压
  2. *.gz 用 gzip -d或者gunzip 解压
  3. .tar.gz和.tgz 用 tar –xzf 解压
  4. *.bz2 用 bzip2 -d或者用bunzip2 解压
  5. *.tar.bz2用tar –xjf 解压
  6. *.Z 用 uncompress 解压
  7. *.tar.Z 用tar –xZf 解压
  8. *.rar 用 unrar e解压
  9. *.zip 用 unzip 解压

    解压的时候,有时候不想覆盖已经存在的文件,那么可以加上-n参数
unzip -n test.zip
unzip -n -d /temp test.zip

只看一下zip压缩包中包含哪些文件,不进行解压缩unzip -l test.zip

查看显示的文件列表还包含压缩比率unzip -v test.zip

检查zip文件是否损坏unzip -t test.zip

如果已有相同的文件存在,要求unzip命令覆盖原先的文件unzip -o test.zip -d /tmp/

示例:

eg1:  unzip mydata.zip -d mydatabak #解压到mydatabak目录
  1. xz

    这是两层压缩,外面是xz压缩方式,里层是tar压缩,所以可以分两步实现解压
$ xz -d node-v6.10.1-linux-x64.tar.xz
$ tar -xvf node-v6.10.1-linux-x64.tar

wget下载与tar压缩/解压的更多相关文章

  1. tar 压缩解压命令详解

    tar -c: 建立压缩档案-x:解压-t:查看内容-r:向压缩归档文件末尾追加文件-u:更新原压缩包中的文件 这五个是独立的命令,压缩解压都要用到其中一个,可以和别的命令连用但只能用其中一个.下面的 ...

  2. Linux下的tar压缩解压命令

    tar  这五个是独立的命令,压缩解压都要用到其中一个,可以和别的命令连用但只能用其中一个. -c: 建立压缩档案-x:解压-t:查看内容-r:向压缩归档文件末尾追加文件-u:更新原压缩包中的文件 下 ...

  3. tar压缩解压文件

    查看visualization1.5.tar.gz 压缩包里面的内容: $ tar -tf visualization1.5.tar.gz 解压指定文件JavascriptVisualRelease/ ...

  4. linux命令tar压缩解压

    tar -c: 建立压缩档案-x:解压-t:查看内容-r:向压缩归档文件末尾追加文件-u:更新原压缩包中的文件 这五个是独立的命令,压缩解压都要用到其中一个,可以和别的命令连用但只能用其中一个.下面的 ...

  5. tar压缩/解压用法

    格式:tar zcvf 压缩后的路径及包名 你要压缩的文件 z:gzip压缩 c:创建压缩包 v:显示打包压缩解压过程 f:接着压缩 t:查看压缩包内容 x:解压 X:指定文件列表形式排除不需要打包压 ...

  6. python tar 压缩解压

    压缩: 1. import tarfile import os def tar(fname): t = tarfile.open(fname + ".tar.gz", " ...

  7. zip unzip tar 压缩解压

    yum install -y unzip zip    yum安装zip -r mydata.zip mydata    mydata目录压缩为mydata.zipunzip mydata.zip - ...

  8. linux下tar压缩/解压的使用(tar) 压缩/解压

    压缩: tar  -zcvf   压缩后文件名.tar.gz   被压缩文件 解压: tar  -zxvf  被解压文件 具体的可以在linux环境下 用 tar --help 查看详细说明格式:ta ...

  9. tar 压缩解压

     tar命令 tar可以为文件和目录创建档案.利用tar,用户可以为某一特定文件创建档案(备份文件),也可以在档案中改变文件, 或者向档案中加入新的文件.tar最初被用来在磁带上创建档案,现在,用户可 ...

随机推荐

  1. Python3数据插MySQL中文乱码解决方案

    1. database要utf8的 CREATE DATABASE spiderTest DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci; 2. ...

  2. redis缓存穿透00

    缓存穿透 缓存穿透,是指查询一个数据库一定不存在的数据.正常的使用缓存流程大致是,数据查询先进行缓存查询,如果key不存在或者key已经过期,再对数据库进行查询,并把查询到的对象,放进缓存.如果数据库 ...

  3. @RequestMapping-限定请求方法的映射

    限定请求方法的映射 测试: 如果非指定的请求方法访问时会出现405状态:

  4. bzoj 4237 稻 草 人

    bzoj 这个矩形有三个限制,分别是右上角点的横纵坐标分别大于左下角废话,并且中间区域没有点.那么可以先按横坐标排序,然后枚举左边的点和右边的点匹配.为了保证复杂度,这里每次把点集一分为二,先递归处理 ...

  5. 中文转拼音,pinyin4j实用示例

    Pinyin4j是一个流行的Java库,支持中文字符和拼音之间的转换.拼音输出格式可以定制. Support Chinese character (both Simplified and Trandi ...

  6. python之requests示例

    一) import requests def download(url, num_tries=, user_agent='wswp', proxies=None): ''' 下载指定url并返回网页内 ...

  7. vue-cli常用配置

    官方配置表:https://cli.vuejs.org/zh/config/#publicpath 1.vue inspect > output.js 将配置按webpack.config.js ...

  8. Linux Exploit系列之四 使用return-to-libc绕过NX bit

    使用return-to-libc绕过NX bit 原文地址:https://bbs.pediy.com/thread-216956.htm 这篇讲解的比较好,主要的问题是获得system地址和exit ...

  9. docker下进去mysql 编写语句

    设置密码可使用 docker exec -it mysql01 bash        --mysql01:数据库名字 mysql -u root -p ALTER USER 'root'@'%' I ...

  10. c# log4net安装时在AssemblyInfo中提示找不到log4net解决办法

    在安装log4net时,按照安装手册需要在AssemblyInfo.cs里添加log4net的配置信息 [assembly: log4net.Config.XmlConfigurator(Config ...