天天看點

【Linux指令】---tar 壓縮解壓

tar

-c: 建立壓縮檔案

-x:解壓

-t:檢視内容

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

-u:更新原壓縮包中的檔案

這五個是獨立的指令,壓縮解壓都要用到其中一個,可以和别的指令連用但隻能用其中一個。下面的參數是根據需要在壓縮或解壓檔案時可選的。

-z:有gzip屬性的

-j:有bz2屬性的

-Z:有compress屬性的

-v:顯示所有過程

-O:将檔案解開到标準輸出

下面的參數-f是必須的

-f: 使用檔案名字,切記,這個參數是最後一個參數,後面隻能接檔案名。

# tar -cf all.tar *.jpg

這條指令是将所有.jpg的檔案打成一個名為all.tar的包。-c是表示産生新的包,-f指定包的檔案名。

# tar -rf all.tar *.gif

這條指令是将所有.gif的檔案增加到all.tar的包裡面去。-r是表示增加檔案的意思。

# tar -uf all.tar logo.gif

這條指令是更新原來tar包all.tar中logo.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壓縮,生成一個gzip壓縮過的包,命名為jpg.tar.gz

 tar -cjf jpg.tar.bz2 *.jpg //将目錄裡所有jpg檔案打包成jpg.tar後,并且将其用bzip2壓縮,生成一個bzip2壓縮過的包,命名為jpg.tar.bz2

tar -cZf jpg.tar.Z *.jpg   //将目錄裡所有jpg檔案打包成jpg.tar後,并且将其用compress壓縮,生成一個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

總結

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

tar

-c: 建立壓縮檔案

-x:解壓

-t:檢視内容

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

-u:更新原壓縮包中的檔案

這五個是獨立的指令,壓縮解壓都要用到其中一個,可以和别的指令連用但隻能用其中一個。下面的參數是根據需要在壓縮或解壓檔案時可選的。

-z:有gzip屬性的

-j:有bz2屬性的

-Z:有compress屬性的

-v:顯示所有過程

-O:将檔案解開到标準輸出

下面的參數-f是必須的

-f: 使用檔案名字,切記,這個參數是最後一個參數,後面隻能接檔案名。

# tar -cf all.tar *.jpg

這條指令是将所有.jpg的檔案打成一個名為all.tar的包。-c是表示産生新的包,-f指定包的檔案名。

# tar -rf all.tar *.gif

這條指令是将所有.gif的檔案增加到all.tar的包裡面去。-r是表示增加檔案的意思。

# tar -uf all.tar logo.gif

這條指令是更新原來tar包all.tar中logo.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壓縮,生成一個gzip壓縮過的包,命名為jpg.tar.gz

 tar -cjf jpg.tar.bz2 *.jpg //将目錄裡所有jpg檔案打包成jpg.tar後,并且将其用bzip2壓縮,生成一個bzip2壓縮過的包,命名為jpg.tar.bz2

tar -cZf jpg.tar.Z *.jpg   //将目錄裡所有jpg檔案打包成jpg.tar後,并且将其用compress壓縮,生成一個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

總結

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

繼續閱讀