系統(tǒng)之家 - 系統(tǒng)光盤下載網(wǎng)站!

當(dāng)前位置:系統(tǒng)之家 > 系統(tǒng)教程 > tar壓縮解壓縮命令詳解

Linux系統(tǒng)下tar壓縮解壓縮命令詳解

時(shí)間:2018-03-05 16:45:08 作者:chunhua 來(lái)源:系統(tǒng)之家 1. 掃描二維碼隨時(shí)看資訊 2. 請(qǐng)使用手機(jī)瀏覽器訪問: https://m.xitongzhijia.net/xtjc/20180305/121507.html 手機(jī)查看 評(píng)論

  tar,是Linux系統(tǒng)的一個(gè)命令,非常好用!如果你對(duì)tar命令不甚了解的話,可以看看小編為大家整理的tar壓縮解壓縮命令詳解。

Linux系統(tǒng)下tar壓縮解壓縮命令詳解

  tar:

  -c: 建立壓縮檔案

  -x:解壓

  -t:查看內(nèi)容

  -r:向壓縮歸檔文件末尾追加文件

  -u:更新原壓縮包中的文件

  這五個(gè)是獨(dú)立的命令,壓縮解壓都要用到其中一個(gè),可以和別的命令連用但只能用其中一個(gè)。下面的參數(shù)是根據(jù)需要在壓縮或解壓檔案時(shí)可選的。

  -z:有g(shù)zip屬性的

  -j:有bz2屬性的

  -Z:有compress屬性的

  -v:顯示所有過程

  -O:將文件解開到標(biāo)準(zhǔn)輸出

  下面的參數(shù)-f是必須的

  -f: 使用檔案名字,切記,這個(gè)參數(shù)是最后一個(gè)參數(shù),后面只能接檔案名。

  # tar -cf all.tar *.jpg

  這條命令是將所有.jpg的文件打成一個(gè)名為all.tar的包。-c是表示產(chǎn)生新的包,-f指定包的文件名。

  # tar -rf all.tar *.gif

  這條命令是將所有.gif的文件增加到all.tar的包里面去。-r是表示增加文件的意思。

  # tar -uf all.tar logo.gif

  這條命令是更新原來(lái)tar包all.tar中l(wèi)ogo.gif文件,-u是表示更新文件的意思。

  # tar -tf all.tar

  這條命令是列出all.tar包中所有文件,-t是列出文件的意思

  # tar -xf all.tar

  這條命令是解出all.tar包中所有文件,-t是解開的意思

  壓縮:

  tar -cvf jpg.tar *.jpg //將目錄里所有jpg文件打包成tar.jpg

  tar -czf jpg.tar.gz *.jpg //將目錄里所有jpg文件打包成jpg.tar后,并且將其用gzip壓縮,生成一個(gè)gzip壓縮過的包,命名為jpg.tar.gz

  tar -cjf jpg.tar.bz2 *.jpg //將目錄里所有jpg文件打包成jpg.tar后,并且將其用bzip2壓縮,生成一個(gè)bzip2壓縮過的包,命名為jpg.tar.bz2

  tar -cZf jpg.tar.Z *.jpg //將目錄里所有jpg文件打包成jpg.tar后,并且將其用compress壓縮,生成一個(gè)umcompress壓縮過的包,命名為jpg.tar.Z

  rar a jpg.rar *.jpg //rar格式的壓縮,需要先下載rar for linux

  zip jpg.zip *.jpg //zip格式的壓縮,需要先下載zip for linux

  解壓:

  tar -xvf file.tar //解壓 tar包

  tar -xzvf file.tar.gz //解壓tar.gz

  tar -xjvf file.tar.bz2 //解壓 tar.bz2

  tar -xZvf file.tar.Z //解壓tar.Z

  unrar e file.rar //解壓rar

  unzip file.zip //解壓zip

  總結(jié):

  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 解壓

  解壓jdk到指定文件夾:

  tar -xzvf jdk-8u131-linux-x64.tar.gz -C /usr/local/java

  1. 01root@ubuntu:~# tar --help
  2. 02用法: tar [選項(xiàng)...] [FILE]...
  3. 03GNU 'tar' saves many files together into a single tape or disk archive, and can
  4. 04restore individual files from the archive.
  5. 05Examples:
  6. 06tar -cf archive.tar foo bar # Create archive.tar from files foo and bar.
  7. 07tar -tvf archive.tar # List all files in archive.tar verbosely.
  8. 08tar -xf archive.tar # Extract all files from archive.tar.
  9. 09主操作模式:
  10. 10-A, --catenate, --concatenate 追加 tar 文件至歸檔
  11. 11-c, --create 創(chuàng)建一個(gè)新歸檔
  12. 12-d, --diff, --compare 找出歸檔和文件系統(tǒng)的差異
  13. 13--delete 從歸檔(非磁帶!)中刪除
  14. 14-r, --append 追加文件至歸檔結(jié)尾
  15. 15-t, --list 列出歸檔內(nèi)容
  16. 16--test-label 測(cè)試歸檔卷標(biāo)并退出
  17. 17-u, --update 僅追加比歸檔中副本更新的文件
  18. 18-x, --extract, --get 從歸檔中解出文件
  19. 19操作修飾符:
  20. 20--check-device 當(dāng)創(chuàng)建增量歸檔時(shí)檢查設(shè)備號(hào)(默認(rèn))
  21. 21-g, --listed-incremental=FILE 處理新式的 GNU 格式的增量備份
  22. 22-G, --incremental 處理老式的 GNU 格式的增量備份
  23. 23--ignore-failed-read
  24. 24當(dāng)遇上不可讀文件時(shí)不要以非零值退出
  25. 25--level=NUMBER 所創(chuàng)建的增量列表歸檔的輸出級(jí)別
  26. 26-n, --seek 歸檔可檢索
  27. 27--no-check-device 當(dāng)創(chuàng)建增量歸檔時(shí)不要檢查設(shè)備號(hào)
  28. 28--no-seek 歸檔不可檢索
  29. 29--occurrence[=NUMBER] 僅處理歸檔中每個(gè)文件的第 NUMBER
  30. 30個(gè)事件;僅當(dāng)與以下子命令 --delete,
  31. 31--diff, --extract 或是 --list
  32. 32中的一個(gè)聯(lián)合使用時(shí),此選項(xiàng)才有效。而且不管文件列表是以命令行形式給出或是通過
  33. 33-T 選項(xiàng)指定的;NUMBER 值默認(rèn)為 1
  34. 34--sparse-version=MAJOR[.MINOR]
  35. 35設(shè)置所用的離散格式版本(隱含
  36. 36--sparse)
  37. 37-S, --sparse 高效處理離散文件
  38. 38重寫控制:
  39. 39-k, --keep-old-files don't replace existing files when extracting,
  40. 40treat them as errors
  41. 41--keep-directory-symlink preserve existing symlinks to directories when
  42. 42extracting
  43. 43--keep-newer-files
  44. 44不要替換比歸檔中副本更新的已存在的文件
  45. 45--no-overwrite-dir 保留已存在目錄的元數(shù)據(jù)
  46. 46--one-top-level[=DIR] create a subdirectory to avoid having loose files
  47. 47extracted
  48. 48--overwrite 解壓時(shí)重寫存在的文件
  49. 49--overwrite-dir 解壓時(shí)重寫已存在目錄的元數(shù)據(jù)(默認(rèn))
  50. 50--recursive-unlink 解壓目錄之前先清除目錄層次
  51. 51--remove-files 在添加文件至歸檔后刪除它們
  52. 52--skip-old-files don't replace existing files when extracting,
  53. 53silently skip over them
  54. 54-U, --unlink-first 在解壓要重寫的文件之前先刪除它們
  55. 55-W, --verify 在寫入以后嘗試校驗(yàn)歸檔
  56. 56選擇輸出流:
  57. 57--ignore-command-error 忽略子進(jìn)程的退出代碼
  58. 58--no-ignore-command-error
  59. 59將子進(jìn)程的非零退出代碼認(rèn)為發(fā)生錯(cuò)誤
  60. 60-O, --to-stdout 解壓文件至標(biāo)準(zhǔn)輸出
  61. 61--to-command=COMMAND
  62. 62將解壓的文件通過管道傳送至另一個(gè)程序
  63. 63操作文件屬性:
  64. 64--atime-preserve[=METHOD]
  65. 65在輸出的文件上保留訪問時(shí)間,要么通過在讀取(默認(rèn)
  66. 66METHOD=‘replace’)后還原時(shí)間,要不就不要在第一次(METHOD=‘system’)設(shè)置時(shí)間
  67. 67--clamp-mtime only set time when the file is more recent than
  68. 68what was given with --mtime
  69. 69--delay-directory-restore
  70. 70直到解壓結(jié)束才設(shè)置修改時(shí)間和所解目錄的權(quán)限
  71. 71--group=名稱 強(qiáng)制將 NAME
  72. 72作為所添加的文件的組所有者
  73. 73--mode=CHANGES 強(qiáng)制將所添加的文件(符號(hào))更改為權(quán)限
  74. 74CHANGES
  75. 75--mtime=DATE-OR-FILE 從 DATE-OR-FILE 中為添加的文件設(shè)置
  76. 76mtime
  77. 77-m, --touch 不要解壓文件的修改時(shí)間
  78. 78--no-delay-directory-restore
  79. 79取消 --delay-directory-restore 選項(xiàng)的效果
  80. 80--no-same-owner
  81. 81將文件解壓為您所有(普通用戶默認(rèn)此項(xiàng))
  82. 82--no-same-permissions
  83. 83從歸檔中解壓權(quán)限時(shí)使用用戶的掩碼位(默認(rèn)為普通用戶服務(wù))
  84. 84--numeric-owner 總是以數(shù)字代表用戶/組的名稱
  85. 85--owner=名稱 強(qiáng)制將 NAME
  86. 86作為所添加的文件的所有者
  87. 87-p, --preserve-permissions, --same-permissions
  88. 88解壓文件權(quán)限信息(默認(rèn)只為超級(jí)用戶服務(wù))
  89. 89--preserve 與 -p 和 -s 一樣
  90. 90--same-owner
  91. 91嘗試解壓時(shí)保持所有者關(guān)系一致(超級(jí)用戶默認(rèn)此項(xiàng))
  92. 92-s, --preserve-order, --same-order
  93. 93member arguments are listed in the same order as
  94. 94the files in the archive
  95. 95--sort=ORDER directory sorting order: none (default), name or
  96. 96inode
  97. 97Handling of extended file attributes:
  98. 98--acls Enable the POSIX ACLs support
  99. 99--no-acls Disable the POSIX ACLs support
  100. 100--no-selinux Disable the SELinux context support
  101. 101--no-xattrs Disable extended attributes support
  102. 102--selinux Enable the SELinux context support
  103. 103--xattrs Enable extended attributes support
  104. 104--xattrs-exclude=MASK specify the exclude pattern for xattr keys
  105. 105--xattrs-include=MASK specify the include pattern for xattr keys
  106. 106設(shè)備選擇和切換:
  107. 107-f, --file=ARCHIVE 使用歸檔文件或 ARCHIVE 設(shè)備
  108. 108--force-local
  109. 109即使歸檔文件存在副本還是把它認(rèn)為是本地歸檔
  110. 110-F, --info-script=名稱, --new-volume-script=名稱
  111. 111在每卷磁帶最后運(yùn)行腳本(隱含 -M)
  112. 112-L, --tape-length=NUMBER 寫入 NUMBER × 1024 字節(jié)后更換磁帶
  113. 113-M, --multi-volume 創(chuàng)建/列出/解壓多卷歸檔文件
  114. 114--rmt-command=COMMAND 使用指定的 rmt COMMAND 代替 rmt
  115. 115--rsh-command=COMMAND 使用遠(yuǎn)程 COMMAND 代替 rsh
  116. 116--volno-file=FILE 使用/更新 FILE 中的卷數(shù)
  117. 117設(shè)備分塊:
  118. 118-b, --blocking-factor=BLOCKS 每個(gè)記錄 BLOCKS x 512 字節(jié)
  119. 119-B, --read-full-records 讀取時(shí)重新分塊(只對(duì) 4.2BSD 管道有效)
  120. 120-i, --ignore-zeros 忽略歸檔中的零字節(jié)塊(即文件結(jié)尾)
  121. 121--record-size=NUMBER 每個(gè)記錄的字節(jié)數(shù) NUMBER,乘以 512
  122. 122選擇歸檔格式:
  123. 123-H, --format=FORMAT 創(chuàng)建指定格式的歸檔
  124. 124FORMAT 是以下格式中的一種:
  125. 125gnu GNU tar 1.13.x 格式
  126. 126oldgnu GNU 格式 as per tar <= 1.12
  127. 127pax POSIX 1003.1-2001 (pax) 格式
  128. 128posix 等同于 pax
  129. 129ustar POSIX 1003.1-1988 (ustar) 格式
  130. 130v7 old V7 tar 格式
  131. 131--old-archive, --portability
  132. 132等同于 --format=v7
  133. 133--pax-option=關(guān)鍵字[[:]=值][,關(guān)鍵字[[:]=值]]...
  134. 134控制 pax 關(guān)鍵字
  135. 135--posix 等同于 --format=posix
  136. 136-V, --label=TEXT 創(chuàng)建帶有卷名 TEXT
  137. 137的歸檔;在列出/解壓時(shí),使用 TEXT
  138. 138作為卷名的模式串
  139. 139壓縮選項(xiàng):
  140. 140-a, --auto-compress 使用歸檔后綴名來(lái)決定壓縮程序
  141. 141-I, --use-compress-program=PROG
  142. 142通過 PROG 過濾(必須是能接受 -d
  143. 143選項(xiàng)的程序)
  144. 144-j, --bzip2 通過 bzip2 過濾歸檔
  145. 145-J, --xz 通過 xz 過濾歸檔
  146. 146--lzip 通過 lzip 過濾歸檔
  147. 147--lzma 通過 xz 過濾歸檔
  148. 148--lzop 通過 xz 過濾歸檔
  149. 149--no-auto-compress 不使用歸檔后綴名來(lái)決定壓縮程序
  150. 150-z, --gzip, --gunzip, --ungzip 通過 gzip 過濾歸檔
  151. 151-Z, --compress, --uncompress 通過 compress 過濾歸檔
  152. 152本地文件選擇:
  153. 153--add-file=FILE 添加指定的 FILE 至歸檔(如果名字以 -
  154. 154開始會(huì)很有用的)
  155. 155--backup[=CONTROL] 在刪除前備份,選擇 CONTROL 版本
  156. 156-C, --directory=DIR 改變至目錄 DIR
  157. 157--exclude=PATTERN 排除以 PATTERN 指定的文件
  158. 158--exclude-backups 排除備份和鎖文件
  159. 159--exclude-caches 除標(biāo)識(shí)文件本身外,排除包含
  160. 160CACHEDIR.TAG 的目錄中的內(nèi)容
  161. 161--exclude-caches-all 排除包含 CACHEDIR.TAG 的目錄
  162. 162--exclude-caches-under 排除包含 CACHEDIR.TAG
  163. 163的目錄中所有內(nèi)容
  164. 164--exclude-ignore=FILE read exclude patterns for each directory from
  165. 165FILE, if it exists
  166. 166--exclude-ignore-recursive=FILE
  167. 167read exclude patterns for each directory and its
  168. 168subdirectories from FILE, if it exists
  169. 169--exclude-tag=FILE 除 FILE 自身外,排除包含 FILE
  170. 170的目錄中的內(nèi)容
  171. 171--exclude-tag-all=FILE 排除包含 FILE 的目錄
  172. 172--exclude-tag-under=FILE 排除包含 FILE 的目錄中的所有內(nèi)容
  173. 173--exclude-vcs 排除版本控制系統(tǒng)目錄
  174. 174--exclude-vcs-ignores read exclude patterns from the VCS ignore files
  175. 175-h, --dereference
  176. 176跟蹤符號(hào)鏈接;將它們所指向的文件歸檔并輸出
  177. 177--hard-dereference
  178. 178跟蹤硬鏈接;將它們所指向的文件歸檔并輸出
  179. 179-K, --starting-file=MEMBER-NAME
  180. 180begin at member MEMBER-NAME when reading the
  181. 181archive
  182. 182--newer-mtime=DATE 當(dāng)只有數(shù)據(jù)改變時(shí)比較數(shù)據(jù)和時(shí)間
  183. 183--no-null 禁用上一次的效果 --null 選項(xiàng)
  184. 184--no-recursion 避免目錄中的自動(dòng)降級(jí)
  185. 185--no-unquote do not unquote input file or member names
  186. 186--null -T 讀取以空終止的名字,-C 禁用
  187. 187-N, --newer=DATE-OR-FILE, --after-date=DATE-OR-FILE
  188. 188只保存比 DATE-OR-FILE 更新的文件
  189. 189--one-file-system 創(chuàng)建歸檔時(shí)保存在本地文件系統(tǒng)中
  190. 190-P, --absolute-names don't strip leading '/'s from file names
  191. 191--recursion 目錄遞歸(默認(rèn))
  192. 192--suffix=STRING 在刪除前備份,除非被環(huán)境變量
  193. 193SIMPLE_BACKUP_SUFFIX
  194. 194覆蓋,否則覆蓋常用后綴(‘’)
  195. 195-T, --files-from=FILE 從 FILE
  196. 196中獲取文件名來(lái)解壓或創(chuàng)建文件
  197. 197--unquote unquote input file or member names (default)
  198. 198-X, --exclude-from=FILE 排除 FILE 中列出的模式串
  199. 199文件名變換:
  200. 200--strip-components=NUMBER 解壓時(shí)從文件名中清除 NUMBER
  201. 201個(gè)引導(dǎo)部分
  202. 202--transform=EXPRESSION, --xform=EXPRESSION
  203. 203使用 sed 代替 EXPRESSION
  204. 204來(lái)進(jìn)行文件名變換
  205. 205文件名匹配選項(xiàng)(同時(shí)影響排除和包括模式串):
  206. 206--anchored 模式串匹配文件名頭部
  207. 207--ignore-case 忽略大小寫
  208. 208--no-anchored patterns match after any '/' (default for
  209. 209exclusion)
  210. 210--no-ignore-case 匹配大小寫(默認(rèn))
  211. 211--no-wildcards 逐字匹配字符串
  212. 212--no-wildcards-match-slash wildcards do not match '/'
  213. 213--wildcards 使用通配符(默認(rèn)對(duì) exclusion )
  214. 214--wildcards-match-slash wildcards match '/' (default for exclusion)
  215. 215提示性輸出:
  216. 216--checkpoint[=NUMBER] 每隔 NUMBER
  217. 217個(gè)記錄顯示進(jìn)度信息(默認(rèn)為 10 個(gè))
  218. 218--checkpoint-action=ACTION 在每個(gè)檢查點(diǎn)上執(zhí)行 ACTION
  219. 219--full-time 按文件原本時(shí)間格式打印
  220. 220--index-file=FILE 將詳細(xì)輸出發(fā)送至 FILE
  221. 221-l, --check-links
  222. 222只要不是所有鏈接都被輸出就打印信息
  223. 223--no-quote-chars=STRING 禁用來(lái)自 STRING 的字符引用
  224. 224--quote-chars=STRING 來(lái)自 STRING 的額外的引用字符
  225. 225--quoting-style=STYLE 設(shè)置名稱引用風(fēng)格;有效的 STYLE
  226. 226值請(qǐng)參閱以下說(shuō)明
  227. 227-R, --block-number 每個(gè)信息都顯示歸檔內(nèi)的塊數(shù)
  228. 228--show-defaults 顯示 tar 默認(rèn)選項(xiàng)
  229. 229--show-omitted-dirs
  230. 230列表或解壓時(shí),列出每個(gè)不匹配查找標(biāo)準(zhǔn)的目錄
  231. 231--show-snapshot-field-ranges
  232. 232show valid ranges for snapshot-file fields
  233. 233--show-transformed-names, --show-stored-names
  234. 234顯示變換后的文件名或歸檔名
  235. 235--totals[=SIGNAL] 處理歸檔后打印出總字節(jié)數(shù);當(dāng)此
  236. 236SIGNAL 被觸發(fā)時(shí)帶參數(shù) -
  237. 237打印總字節(jié)數(shù);允許的信號(hào)為:
  238. 238SIGHUP,SIGQUIT,SIGINT,SIGUSR1 和
  239. 239SIGUSR2;同時(shí)也接受不帶 SIG
  240. 240前綴的信號(hào)名稱
  241. 241--utc 以 UTC 格式打印文件修改時(shí)間
  242. 242-v, --verbose 詳細(xì)地列出處理的文件
  243. 243--warning=KEYWORD 警告控制:
  244. 244-w, --interactive, --confirmation
  245. 245每次操作都要求確認(rèn)
  246. 246兼容性選項(xiàng):
  247. 247-o 創(chuàng)建歸檔時(shí),相當(dāng)于
  248. 248--old-archive;展開歸檔時(shí),相當(dāng)于
  249. 249--no-same-owner
  250. 250其它選項(xiàng):
  251. 251-?, --help 顯示此幫助列表
  252. 252--restrict 禁用某些潛在的有危險(xiǎn)的選項(xiàng)
  253. 253--usage 顯示簡(jiǎn)短的用法說(shuō)明
  254. 254--version 打印程序版本
  255. 255長(zhǎng)選項(xiàng)和相應(yīng)短選項(xiàng)具有相同的強(qiáng)制參數(shù)或可選參數(shù)。
  256. 256The backup suffix is '~', unless set with --suffix or SIMPLE_BACKUP_SUFFIX.
  257. 257The version control may be set with --backup or VERSION_CONTROL, values are:
  258. 258none, off never make backups
  259. 259t, numbered make numbered backups
  260. 260nil, existing numbered if numbered backups exist, simple otherwise
  261. 261never, simple always make simple backups
  262. 262--quoting-style 選項(xiàng)的有效參數(shù)為:
  263. 263literal
  264. 264shell
  265. 265shell-always
  266. 266c
  267. 267c-maybe
  268. 268escape
  269. 269locale
  270. 270clocale
  271. 271此 tar 默認(rèn)為:
  272. 272--format=gnu -f- -b20 --quoting-style=escape --rmt-command=/usr/lib/tar/rmt
  273. 273--rsh-command=/usr/bin/rsh
  274. 274將錯(cuò)誤報(bào)告發(fā)送到 <bug-tar@gnu.org>。
復(fù)制代碼
root@ubuntu:~# tar --help 用法: tar [選項(xiàng)...] [FILE]... GNU 'tar' saves many files together into a single tape or disk archive, and can restore individual files from the archive. Examples: tar -cf archive.tar foo bar # Create archive.tar from files foo and bar. tar -tvf archive.tar # List all files in archive.tar verbosely. tar -xf archive.tar # Extract all files from archive.tar. 主操作模式: -A, --catenate, --concatenate 追加 tar 文件至歸檔 -c, --create 創(chuàng)建一個(gè)新歸檔 -d, --diff, --compare 找出歸檔和文件系統(tǒng)的差異 --delete 從歸檔(非磁帶!)中刪除 -r, --append 追加文件至歸檔結(jié)尾 -t, --list 列出歸檔內(nèi)容 --test-label 測(cè)試歸檔卷標(biāo)并退出 -u, --update 僅追加比歸檔中副本更新的文件 -x, --extract, --get 從歸檔中解出文件 操作修飾符: --check-device 當(dāng)創(chuàng)建增量歸檔時(shí)檢查設(shè)備號(hào)(默認(rèn)) -g, --listed-incremental=FILE 處理新式的 GNU 格式的增量備份 -G, --incremental 處理老式的 GNU 格式的增量備份 --ignore-failed-read 當(dāng)遇上不可讀文件時(shí)不要以非零值退出 --level=NUMBER 所創(chuàng)建的增量列表歸檔的輸出級(jí)別 -n, --seek 歸檔可檢索 --no-check-device 當(dāng)創(chuàng)建增量歸檔時(shí)不要檢查設(shè)備號(hào) --no-seek 歸檔不可檢索 --occurrence[=NUMBER] 僅處理歸檔中每個(gè)文件的第 NUMBER 個(gè)事件;僅當(dāng)與以下子命令 --delete, --diff, --extract 或是 --list 中的一個(gè)聯(lián)合使用時(shí),此選項(xiàng)才有效。而且不管文件列表是以命令行形式給出或是通過 -T 選項(xiàng)指定的;NUMBER 值默認(rèn)為 1 --sparse-version=MAJOR[.MINOR] 設(shè)置所用的離散格式版本(隱含 --sparse) -S, --sparse 高效處理離散文件 重寫控制: -k, --keep-old-files don't replace existing files when extracting, treat them as errors --keep-directory-symlink preserve existing symlinks to directories when extracting --keep-newer-files 不要替換比歸檔中副本更新的已存在的文件 --no-overwrite-dir 保留已存在目錄的元數(shù)據(jù) --one-top-level[=DIR] create a subdirectory to avoid having loose files extracted --overwrite 解壓時(shí)重寫存在的文件 --overwrite-dir 解壓時(shí)重寫已存在目錄的元數(shù)據(jù)(默認(rèn)) --recursive-unlink 解壓目錄之前先清除目錄層次 --remove-files 在添加文件至歸檔后刪除它們 --skip-old-files don't replace existing files when extracting, silently skip over them -U, --unlink-first 在解壓要重寫的文件之前先刪除它們 -W, --verify 在寫入以后嘗試校驗(yàn)歸檔 選擇輸出流: --ignore-command-error 忽略子進(jìn)程的退出代碼 --no-ignore-command-error 將子進(jìn)程的非零退出代碼認(rèn)為發(fā)生錯(cuò)誤 -O, --to-stdout 解壓文件至標(biāo)準(zhǔn)輸出 --to-command=COMMAND 將解壓的文件通過管道傳送至另一個(gè)程序 操作文件屬性: --atime-preserve[=METHOD] 在輸出的文件上保留訪問時(shí)間,要么通過在讀取(默認(rèn) METHOD=‘replace’)后還原時(shí)間,要不就不要在第一次(METHOD=‘system’)設(shè)置時(shí)間 --clamp-mtime only set time when the file is more recent than what was given with --mtime --delay-directory-restore 直到解壓結(jié)束才設(shè)置修改時(shí)間和所解目錄的權(quán)限 --group=名稱 強(qiáng)制將 NAME 作為所添加的文件的組所有者 --mode=CHANGES 強(qiáng)制將所添加的文件(符號(hào))更改為權(quán)限 CHANGES --mtime=DATE-OR-FILE 從 DATE-OR-FILE 中為添加的文件設(shè)置 mtime -m, --touch 不要解壓文件的修改時(shí)間 --no-delay-directory-restore 取消 --delay-directory-restore 選項(xiàng)的效果 --no-same-owner 將文件解壓為您所有(普通用戶默認(rèn)此項(xiàng)) --no-same-permissions 從歸檔中解壓權(quán)限時(shí)使用用戶的掩碼位(默認(rèn)為普通用戶服務(wù)) --numeric-owner 總是以數(shù)字代表用戶/組的名稱 --owner=名稱 強(qiáng)制將 NAME 作為所添加的文件的所有者 -p, --preserve-permissions, --same-permissions 解壓文件權(quán)限信息(默認(rèn)只為超級(jí)用戶服務(wù)) --preserve 與 -p 和 -s 一樣 --same-owner 嘗試解壓時(shí)保持所有者關(guān)系一致(超級(jí)用戶默認(rèn)此項(xiàng)) -s, --preserve-order, --same-order member arguments are listed in the same order as the files in the archive --sort=ORDER directory sorting order: none (default), name or inode Handling of extended file attributes: --acls Enable the POSIX ACLs support --no-acls Disable the POSIX ACLs support --no-selinux Disable the SELinux context support --no-xattrs Disable extended attributes support --selinux Enable the SELinux context support --xattrs Enable extended attributes support --xattrs-exclude=MASK specify the exclude pattern for xattr keys --xattrs-include=MASK specify the include pattern for xattr keys 設(shè)備選擇和切換: -f, --file=ARCHIVE 使用歸檔文件或 ARCHIVE 設(shè)備 --force-local 即使歸檔文件存在副本還是把它認(rèn)為是本地歸檔 -F, --info-script=名稱, --new-volume-script=名稱 在每卷磁帶最后運(yùn)行腳本(隱含 -M) -L, --tape-length=NUMBER 寫入 NUMBER × 1024 字節(jié)后更換磁帶 -M, --multi-volume 創(chuàng)建/列出/解壓多卷歸檔文件 --rmt-command=COMMAND 使用指定的 rmt COMMAND 代替 rmt --rsh-command=COMMAND 使用遠(yuǎn)程 COMMAND 代替 rsh --volno-file=FILE 使用/更新 FILE 中的卷數(shù) 設(shè)備分塊: -b, --blocking-factor=BLOCKS 每個(gè)記錄 BLOCKS x 512 字節(jié) -B, --read-full-records 讀取時(shí)重新分塊(只對(duì) 4.2BSD 管道有效) -i, --ignore-zeros 忽略歸檔中的零字節(jié)塊(即文件結(jié)尾) --record-size=NUMBER 每個(gè)記錄的字節(jié)數(shù) NUMBER,乘以 512 選擇歸檔格式: -H, --format=FORMAT 創(chuàng)建指定格式的歸檔 FORMAT 是以下格式中的一種: gnu GNU tar 1.13.x 格式 oldgnu GNU 格式 as per tar <= 1.12 pax POSIX 1003.1-2001 (pax) 格式 posix 等同于 pax ustar POSIX 1003.1-1988 (ustar) 格式 v7 old V7 tar 格式 --old-archive, --portability 等同于 --format=v7 --pax-option=關(guān)鍵字[[:]=值][,關(guān)鍵字[[:]=值]]... 控制 pax 關(guān)鍵字 --posix 等同于 --format=posix -V, --label=TEXT 創(chuàng)建帶有卷名 TEXT 的歸檔;在列出/解壓時(shí),使用 TEXT 作為卷名的模式串 壓縮選項(xiàng): -a, --auto-compress 使用歸檔后綴名來(lái)決定壓縮程序 -I, --use-compress-program=PROG 通過 PROG 過濾(必須是能接受 -d 選項(xiàng)的程序) -j, --bzip2 通過 bzip2 過濾歸檔 -J, --xz 通過 xz 過濾歸檔 --lzip 通過 lzip 過濾歸檔 --lzma 通過 xz 過濾歸檔 --lzop 通過 xz 過濾歸檔 --no-auto-compress 不使用歸檔后綴名來(lái)決定壓縮程序 -z, --gzip, --gunzip, --ungzip 通過 gzip 過濾歸檔 -Z, --compress, --uncompress 通過 compress 過濾歸檔 本地文件選擇: --add-file=FILE 添加指定的 FILE 至歸檔(如果名字以 - 開始會(huì)很有用的) --backup[=CONTROL] 在刪除前備份,選擇 CONTROL 版本 -C, --directory=DIR 改變至目錄 DIR --exclude=PATTERN 排除以 PATTERN 指定的文件 --exclude-backups 排除備份和鎖文件 --exclude-caches 除標(biāo)識(shí)文件本身外,排除包含 CACHEDIR.TAG 的目錄中的內(nèi)容 --exclude-caches-all 排除包含 CACHEDIR.TAG 的目錄 --exclude-caches-under 排除包含 CACHEDIR.TAG 的目錄中所有內(nèi)容 --exclude-ignore=FILE read exclude patterns for each directory from FILE, if it exists --exclude-ignore-recursive=FILE read exclude patterns for each directory and its subdirectories from FILE, if it exists --exclude-tag=FILE 除 FILE 自身外,排除包含 FILE 的目錄中的內(nèi)容 --exclude-tag-all=FILE 排除包含 FILE 的目錄 --exclude-tag-under=FILE 排除包含 FILE 的目錄中的所有內(nèi)容 --exclude-vcs 排除版本控制系統(tǒng)目錄 --exclude-vcs-ignores read exclude patterns from the VCS ignore files -h, --dereference 跟蹤符號(hào)鏈接;將它們所指向的文件歸檔并輸出 --hard-dereference 跟蹤硬鏈接;將它們所指向的文件歸檔并輸出 -K, --starting-file=MEMBER-NAME begin at member MEMBER-NAME when reading the archive --newer-mtime=DATE 當(dāng)只有數(shù)據(jù)改變時(shí)比較數(shù)據(jù)和時(shí)間 --no-null 禁用上一次的效果 --null 選項(xiàng) --no-recursion 避免目錄中的自動(dòng)降級(jí) --no-unquote do not unquote input file or member names --null -T 讀取以空終止的名字,-C 禁用 -N, --newer=DATE-OR-FILE, --after-date=DATE-OR-FILE 只保存比 DATE-OR-FILE 更新的文件 --one-file-system 創(chuàng)建歸檔時(shí)保存在本地文件系統(tǒng)中 -P, --absolute-names don't strip leading '/'s from file names --recursion 目錄遞歸(默認(rèn)) --suffix=STRING 在刪除前備份,除非被環(huán)境變量 SIMPLE_BACKUP_SUFFIX 覆蓋,否則覆蓋常用后綴(‘’) -T, --files-from=FILE 從 FILE 中獲取文件名來(lái)解壓或創(chuàng)建文件 --unquote unquote input file or member names (default) -X, --exclude-from=FILE 排除 FILE 中列出的模式串 文件名變換: --strip-components=NUMBER 解壓時(shí)從文件名中清除 NUMBER 個(gè)引導(dǎo)部分 --transform=EXPRESSION, --xform=EXPRESSION 使用 sed 代替 EXPRESSION 來(lái)進(jìn)行文件名變換 文件名匹配選項(xiàng)(同時(shí)影響排除和包括模式串): --anchored 模式串匹配文件名頭部 --ignore-case 忽略大小寫 --no-anchored patterns match after any '/' (default for exclusion) --no-ignore-case 匹配大小寫(默認(rèn)) --no-wildcards 逐字匹配字符串 --no-wildcards-match-slash wildcards do not match '/' --wildcards 使用通配符(默認(rèn)對(duì) exclusion ) --wildcards-match-slash wildcards match '/' (default for exclusion) 提示性輸出: --checkpoint[=NUMBER] 每隔 NUMBER 個(gè)記錄顯示進(jìn)度信息(默認(rèn)為 10 個(gè)) --checkpoint-action=ACTION 在每個(gè)檢查點(diǎn)上執(zhí)行 ACTION --full-time 按文件原本時(shí)間格式打印 --index-file=FILE 將詳細(xì)輸出發(fā)送至 FILE -l, --check-links 只要不是所有鏈接都被輸出就打印信息 --no-quote-chars=STRING 禁用來(lái)自 STRING 的字符引用 --quote-chars=STRING 來(lái)自 STRING 的額外的引用字符 --quoting-style=STYLE 設(shè)置名稱引用風(fēng)格;有效的 STYLE 值請(qǐng)參閱以下說(shuō)明 -R, --block-number 每個(gè)信息都顯示歸檔內(nèi)的塊數(shù) --show-defaults 顯示 tar 默認(rèn)選項(xiàng) --show-omitted-dirs 列表或解壓時(shí),列出每個(gè)不匹配查找標(biāo)準(zhǔn)的目錄 --show-snapshot-field-ranges show valid ranges for snapshot-file fields --show-transformed-names, --show-stored-names 顯示變換后的文件名或歸檔名 --totals[=SIGNAL] 處理歸檔后打印出總字節(jié)數(shù);當(dāng)此 SIGNAL 被觸發(fā)時(shí)帶參數(shù) - 打印總字節(jié)數(shù);允許的信號(hào)為: SIGHUP,SIGQUIT,SIGINT,SIGUSR1 和 SIGUSR2;同時(shí)也接受不帶 SIG 前綴的信號(hào)名稱 --utc 以 UTC 格式打印文件修改時(shí)間 -v, --verbose 詳細(xì)地列出處理的文件 --warning=KEYWORD 警告控制: -w, --interactive, --confirmation 每次操作都要求確認(rèn) 兼容性選項(xiàng): -o 創(chuàng)建歸檔時(shí),相當(dāng)于 --old-archive;展開歸檔時(shí),相當(dāng)于 --no-same-owner 其它選項(xiàng): -?, --help 顯示此幫助列表 --restrict 禁用某些潛在的有危險(xiǎn)的選項(xiàng) --usage 顯示簡(jiǎn)短的用法說(shuō)明 --version 打印程序版本 長(zhǎng)選項(xiàng)和相應(yīng)短選項(xiàng)具有相同的強(qiáng)制參數(shù)或可選參數(shù)。 The backup suffix is '~', unless set with --suffix or SIMPLE_BACKUP_SUFFIX. The version control may be set with --backup or VERSION_CONTROL, values are: none, off never make backups t, numbered make numbered backups nil, existing numbered if numbered backups exist, simple otherwise never, simple always make simple backups --quoting-style 選項(xiàng)的有效參數(shù)為: literal shell shell-always c c-maybe escape locale clocale 此 tar 默認(rèn)為: --format=gnu -f- -b20 --quoting-style=escape --rmt-command=/usr/lib/tar/rmt --rsh-command=/usr/bin/rsh 將錯(cuò)誤報(bào)告發(fā)送到 <bug-tar@gnu.org>。

  關(guān)于Linux下的tar壓縮解壓縮命令就給大家敘述到這里了,使用Linux系統(tǒng)的用戶,可以多做了解!

發(fā)表評(píng)論

0

沒有更多評(píng)論了

評(píng)論就這些咯,讓大家也知道你的獨(dú)特見解

立即評(píng)論

以上留言僅代表用戶個(gè)人觀點(diǎn),不代表系統(tǒng)之家立場(chǎng)

其他版本軟件

熱門教程

人氣教程排行

Linux系統(tǒng)推薦

官方交流群 軟件收錄