.TH TAR 1 "Mar 2010" "GNU" "tar" .SH 名字 tar \- tar 檔案檔案管理程式的 GNU 版本。 .SH 總覽 .B tar .I <操作引數> [選項] .I 操作引數: .nf .B [-]A --catenate --concatenate .B [-]c --create .B [-]d --diff --compare .B [-]r --append .B [-]t --list .B [-]u --update .B [-]x --extract --get .B --delete .fi .I 常用選項: .nf .BR -C ", " --directory " 目錄" .BR -f ", " --file " 檔案" .BR -j ", " --bzip2 .BR -J ", " --xz .BR -p ", " --preserve-permissions .BR -v ", " --verbose .BR -z ", " --gzip .fi .I 所有選項: .br [ .BR -a ", " --auto-compress ] [ .BR --add-file " 檔案" ] [ .BR --anchored ] [ .BR --atime-preserve ] [ .BR -b ", " --blocking-factor " N" ] [ .BR -B ", " --read-full-records ] [ .BR --backup "[=備份型別]" ] [ .BR --block-compress ] [ .BR -C ", " --directory " 目錄" ] [ .BR --checkpoint ] [ .BR --delay-directory-restore ] [ .BR --exclude " 檔案或目錄" ] [ .BR --exclude-caches ] [ .BR --exclude-caches-all ] [ .BR --exclude-caches-under ] [ .BR --exclude-tag " 檔案" ] [ .BR --exclude-tag-all " 檔案" ] [ .BR --exclude-tag-under " 檔案" ] [ .BR -f ", " --file " [主機名:]檔案" ] [ .BR -F ", " --info-script " 檔案, " --new-volume-script " 檔案" ] [ .BR --force-local ] [ .BR --format " 格式" ] [ .BR -g ", " --listed-incremental " 快照" ] [ .BR -G ", " --incremental ] [ .BR --group " 組" ] [ .BR -h ", " --dereference ] [ .BR --help ] [ .BR -i ", " --ignore-zeros ] [ .BR -I ", " --use-compress-program " 程式" ] [ .BR --ignore-case ] [ .BR --ignore-command-error ] [ .BR --ignore-failed-read ] [ .BR --index-file " 檔案" ] [ .BR -j ", " --bzip2 ] [ .BR -J ", " --xz ] [ .BR -k ", " --keep-old-files ] [ .BR -K ", " --starting-file " 檔案" ] [ .BR --keep-newer-files ] [ .BR -l ", " --check-links ] [ .BR -L ", " --tape-length " N" ] [ .BR --lzip ] [ .BR --lzma ] [ .BR --lzop ] [ .BR -m ", " --touch ", " --modification-time ] [ .BR -M ", " --multi-volume ] [ .BR --mode " 許可權" ] [ .BR --mtime " 日期" ] [ .BR -N ", " --after-date " 日期, " --newer " 日期" ] [ .BR --newer-mtime " 日期" ] [ .BR --no-anchored ] [ .BR --no-auto-compress ] [ .BR --no-delay-directory-restore ] [ .BR --no-ignore-case ] [ .BR --no-ignore-command-error ] [ .BR --no-overwrite-dir ] [ .BR --no-quote-chars ] [ .BR --no-recursion ] [ .BR --no-same-permissions ] [ .BR --no-unquote ] [ .BR --no-wildcards ] [ .BR --no-wildcards-match-slash ] [ .BR --null ] [ .BR --numeric-owner ] [ .BR -o ", " --old-archive ", " --portability ", " --no-same-owner ] [ .BR -O ", " --to-stdout ] [ .BR --occurrence " 次數" ] [ .BR --one-file-system ] [ .BR --overwrite ] [ .BR --overwrite-dir ] [ .BR --owner " 使用者" ] [ .BR -p ", " --same-permissions ", " --preserve-permissions ] [ .BR -P ", " --absolute-names ] [ .BR --pax-option " 關鍵字列表" ] [ .BR --posix ] [ .BR --preserve ] [ .BR --quote-chars " 字串" ] [ .BR --quote-style " 風格" ] [ .BR -R ", " --block-number ] [ .BR --record-size " 位元組數" ] [ .BR --recursion ] [ .BR --recursive-unlink ] [ .BR --remove-files ] [ .BR --restrict ] [ .BR --rmt-command " 命令" ] [ .BR --rsh-command " 命令" ] [ .BR -s ", " --same-order ", " --preserve-order ] [ .BR -S ", " --sparse ] [ .BR --same-owner ] [ .BR --show-defaults ] [ .BR --show-omitted-dirs ] [ .BR --show-transformed-names ", " --show-stored-names ] [ .BR --strip-components " 目錄層數" ] [ .BR --suffix " 字尾" ] [ .BR -T ", " --files-from " 檔案" ] [ .BR --test-label ] [ .BR --to-command " 命令" ] [ .BR --transform " sed表示式" ] [ .BR --totals ] [ .BR -U ", " --unlink-first ] [ .BR --unquote ] [ .BR --utc ] [ .BR -v ", " --verbose ] [ .BR -V ", " --label " 名稱" ] [ .BR --version ] [ .BR --volno-file " 檔案" ] [ .BR -w ", " --interactive ", " --confirmation ] [ .BR -W ", " --verify ] [ .BR --wildcards ] [ .BR --wildcards-match-slash ] [ .BR -X ", " --exclude-from " 檔案" ] [ .BR -z ", " --gzip ", " --gunzip ", " --ungzip ] [ .BR -Z ", " --compress ", " --uncompress ] [ .BR -[0-7][lmh] ] .SH 描述 這是\fBtar\fR的GNU版本的手冊頁。 \fBtar\fR是一個用於儲存或提取\fItar檔案\fR的程式。 \fItar檔案\fR可放在磁碟中, 也可以存為普通檔案。 \fBtar\fR\ 的第一個引數必須是操作引數A、c、d、r、t、u、x 中的一個, 引數後面可跟著任意可選選項。 \fBtar\fR的最後一個引數是你要處理的檔案或目錄的名字。 如果你指定了一個目錄, 該目錄的所有子目錄都將被加入存檔。 .SH 應用舉例 .TP .B tar -xvf foo.tar 提取 foo.tar 檔案並顯示提取過程 .TP .B tar -xzf foo.tar.gz 提取用 gzip 壓縮的檔案 foo.tar.gz .TP .B tar -cjf foo.tar.bz2 bar/ 用 bzip 為目錄 bar 建立一個叫做 foo.tar.bz2存檔 .TP .B tar -xjf foo.tar.bz2 -C bar/ 把用 bzip 壓縮的檔案 foo.tar.bz2 提取到 bar 目錄 .TP .B tar -xzf foo.tar.gz blah.txt 把檔案 blah.txt 從 foo.tar.gz 中提取出來 .P 注意: 當壓縮或提取的時候, 壓縮型別選項常常是不必需的, 因為\fBtar\fR會根據檔案的字尾自動選擇壓縮型別。 .SH "引數說明" .TP .B 下列引數中必須有至少一個被使用: .TP .BR -A ", " --catenate ", " --concatenate 將一存檔與已有的存檔合併 .TP .BR -c ", " --create 建立一個新的存檔 .TP .BR -d ", " --diff ", " --compare 比較存檔與相應的未存檔檔案的不同之處 .TP .BR -r ", " --append 將檔案附加到存檔結尾 .TP .BR -t ", " --list 列出存檔中檔案的目錄 .TP .BR -u ", " --update 僅將較新的檔案附加到存檔中 .TP .BR -x ", " --extract ", " --get 從存檔提取檔案 .TP .BR --delete 把指定檔案從存檔中刪除(不要用於磁帶!) .SH "常用選項" .TP .BR -C ", " --directory " 目錄" 提取存檔到指定目錄 .TP .BR -f ", " --file " [主機名:]檔案" 指定存檔或裝置中的檔案 (預設是\ "-",\ 表示\ 標準輸入/輸出) .TP .BR -j ", " --bzip2 用 bzip2 處理存檔;\ 用於\ .bz2\ 檔案 .TP .BR -J ", " --xz 用 xz 處理存檔;\ 用於\ .xz\ 檔案 .TP .BR -p ", " --preserve-permissions 提取所有保護資訊 .TP .BR -v ", " --verbose 顯示檔案處理過程 .TP .BR -z ", " --gzip ", " --ungzip 用 gzip 處理存檔;\ 用於\ .gz\ 檔案 .SH "所有選項" .TP .BR -a ", " --auto-compress 根據存檔字尾來選擇壓縮程式 .TP .BR --add-file " 檔案" 新增指定檔案到存檔 (對以下標線開頭的檔案很有用) .TP .BR --anchored patterns will match the start of file names .TP .BR --atime-preserve 不改變存檔中檔案的訪問時間 .TP .BR -b ", " --blocking-factor " N" 指定塊大小為 Nx512 位元組(預設N=20) .TP .BR -B ", " --read-full-blocks 讀取時重組塊\ (用於讀取4.2BSD pipes) .TP .BR --backup "[=備份型別]" 備份檔案而不是刪除它們, 備份型別有simple、numbered等 .TP .BR --block-compress 讓磁帶的輸出結果成塊輸出 .TP .BR -C ", " --directory " 目錄" 提取文件到指定目錄 .TP .BR --checkpoint 讀取存檔時顯示目錄名 .TP .BR --delay-directory-restore 延遲對已提取目錄的修改時間和許可權的設定, 直到提取結束 .TP .BR --exclude " 檔案或目錄" 排除指定檔案或目錄 .TP .BR --exclude-caches 排除帶有\ 快取目錄\ 標記的目錄 .TP .BR --exclude-tag " 檔案" 排除包含指定檔案的目錄 .TP .BR -f ", " --file " [主機名:]檔案" 指定存檔或裝置中的檔案 (預設是\ "-",\ 表示\ 標準輸入/輸出) .TP .BR -F ", " --info-script " 檔案, " --new-volume-script " 檔案" 在每卷磁帶的結尾執行指令碼 (會應用\fI--multi-volume\fR選項) .TP .BR --force-local 存檔檔案是本地的,\ 即使它的名稱中含有冒號 .TP .BR --format " FORMAT" 選擇建立存檔的格式 .nf \fIv7\fR - Unix V7 \fIoldgnu\fR - GNU tar <=1.12 \fIgnu\fR - GNU tar 1.13 \fIustar\fR - POSIX.1-1988 \fIposix\fR - POSIX.1-2001 .fi .TP .BR -g ", " --listed-incremental " 快照" 建立/列出/提取\ 新GNU格式的增量備份 .TP .BR --group " 組" 將新增到存檔的檔案的組標識設定為指定組, 而不是原始檔所在的組; 這個選項對提取無效 .TP .BR -G ", " --incremental 建立/列出/提取\ 舊GNU格式的增量備份 .TP .BR -h ", " --dereference 不存入符號連結;\ 存入連結指向的檔案 .TP .BR --help 顯示像本手冊這樣的幫助資訊, 但不像這麼詳細 .TP .BR -i ", " --ignore-zeros 忽略存檔中的 0 位元組塊 (那通常意味著檔案結束) .TP .BR -I ", " --use-compress-program " 程式" 透過指定程式訪問存檔 (該程式通常是一個壓縮程式; 它需能接受\ \fI-d\fR\ 引數) .TP .BR --ignore-case 排除檔案時不區分大小寫 .TP .BR --ignore-command-error 忽略子程式的退出程式碼 .TP .BR --ignore-failed-read 遇到不可讀檔案的非零狀態不退出 .TP .BR --index-file " 檔案" 將處理過程資訊輸出到指定檔案, 而不是輸出到標準輸出 .TP .BR -j ", " --bzip2 用 bzip2 處理存檔,\ 用於\ .bz2\ 檔案 .TP .BR -J ", " --xz 用 xz 處理存檔,\ 用於\ .xz\ 檔案 .TP .BR -k ", " --keep-old-files 保留已存在的檔案;\ 不用存檔中的檔案覆蓋它們 .TP .BR -K ", " --starting-file " FILE" 從存檔中的指定檔案處開始 .TP .BR --keep-newer-files 不覆蓋比存檔新的檔案 .TP .BR -l ", " --check-links 如果檔案系統中檔案的硬連結數和存檔中記錄的不同, 則發出警告 .TP .BR -L ", " --tape-length " N" 在寫入了N*1024位元組後, 更換磁帶 .TP .BR -m ", " --touch ", " --modification-time 不提取檔案的修改時間 .TP .BR -M ", " --multi-volume 建立/列出/提取 多卷存檔 .TP .BR --mode " 許可權" 新增檔案時應用指定的許可權 (參看\ \fBchmod\fR(1)) .TP .BR --mtime " 日期" 當建立存檔時,\ 使用指定日期作為存檔成員的修改日期, 而不是使用檔案的實際修改時間 .TP .BR -N ", " --after-date " 日期, " --newer " 日期" 只儲存在指定日期後有修改或狀態更新 (許可權,\ ACLs,\ 擴充套件屬性,\ ...)的檔案 .TP .BR --newer-mtime " 日期" 和\ \fI--newer\fR\ 類似, 但是隻儲存指定日期後有修改的檔案 .TP .BR --no-anchored 匹配任意‘/’後字元項\fI--exclude\fR一起使用 .TP .BR --no-auto-compress 不根據存檔字尾來決定使用哪個壓縮程式 .TP .BR --no-delay-directory-restore 在目錄中的所有檔案都被提取完成時, 就設定該目錄的修改時間和許可權; 這是預設設定 .TP .BR --no-ignore-command-error 對以非零狀態終止的子程式的顯示警告 .TP .BR --no-ignore-case 用\ \fI--exclude\fR\ 匹配時區分大小寫 .TP .BR --no-overwrite-dir 從存檔中提取檔案時,\ 保留已存在目錄的元資料。 .TP .BR --no-quote-chars " 字串" 把指定字串中的字元從\fI--quote-chars\fR選項指定的字元中去除 .TP .BR --no-recursion 不遞迴進入子目錄 .TP .BR --no-same-permissions 提取時應用使用者的umask, 而不是用已記錄的許可權 .TP .BR --no-unquote 將所有輸入檔案或成員的名字作為普通文字, 不解釋轉義序列 .TP .BR --no-wildcards 不對\fI--exclude\fR使用萬用字元 .TP .BR --no-wildcards-match-slash \fI--exclude\fR的萬用字元不匹配斜槓(/) .TP .BR --null \fI--files-from\fR讀取以空值終止的名字, 禁用\fI--directory\fR .TP .BR --numeric-owner 總是用數字作為 使用者/組 的名字 .TP .BR -o ", " --old-archive ", " --portability 相當於\fI--format=v7\fR; 當建立存檔時\fI-o\fR選項表示這個行為 (已棄用的行為) .TP .BR -o ", " --no-same-owner 提取時不恢復所有權; 當提取時\fI-o\fR選項表示這個行為 .TP .BR -O ", " --to-stdout 將檔案提取到標準輸出 .TP .BR --occurrence " 次數" 只處理指定次數每個已被命名的檔案的在操作中的出現; 用於\fI--delete\fR, \fI--diff\fR, \fI--extract\fR, 或 \fI--list\fR .TP .BR --one-file-system 建立存檔時停留在本地檔案系統 .TP .BR --overwrite 提取時覆蓋已存在的檔案和目錄中的元資料 .TP .BR --overwrite-dir 提取時覆蓋目錄中的元資料 .TP .BR --owner " 使用者" 將檔案所有者設為指定使用者, 而不是原檔案的所有者; 這個選項對提取無效 .TP .BR -p ", " --preserve-permissions ", " --same-permissions 提取所有保護資訊 .TP .BR -P ", " --absolute-names 將檔名開頭的“/”符號看作檔名的一部分 .TP .BR --pax-option " 關鍵字列表" 修改\fBtar\fR處理擴充套件頭關鍵字的方式, 只用於POSIX.1-2001存檔 .TP .BR --posix 相當於\fI--format=posix\fR .TP .BR --preserve 相當於\fI--preserve-permissions\fR加上\fI--same-order\fR .TP .BR --quote-chars " 字串" 總是標出指定字串中包含的的字元, 即使已選擇的標識風格不標識它們 .TP .BR --quote-style " 風格" 設定顯示成員和檔名稱的標識風格 .TP .BR -R ", " --record-number 顯示存檔中每條資訊的記錄數字 .TP .BR --record-size " 位元組數" 訪問存檔時每條記錄使用指定的位元組數 .TP .BR --recursion 遞迴進入目錄 .TP .BR --recursive-unlink 提取目錄之前先把存在的相同名稱的目錄刪除 .TP .BR --remove-files 把檔案加入到存檔後刪除這些檔案 .TP .BR --restrict 禁用一些有潛在害處的選項; 目前這會禁用多卷選單中對shell的呼叫 .TP .BR --rmt-command " 命令" 用指定的命令代替預設的/usr/sbin/rmt .TP .BR --rsh-command " 命令" 用指定的遠端命令代替\fBrsh\fR(1) .TP .BR -s ", " --same-order ", " --preserve-order 名稱列表會被排序以匹配存檔 .TP .BR -S ", " --sparse 高效地處理稀疏檔案 .TP .BR --same-owner 以相同的所有權建立提取出的檔案 .TP .BR --show-defaults 顯示\fBtar\fR使用的預設選項 .TP .BR --show-omitted-dirs 顯示提取時\fBtar\fR跳過的目錄 .TP .BR --show-transformed-names ", " --show-stored-names 應用了任何\fBsed\fR轉換之後, 顯示檔案或成員名字 .TP .BR --strip-components " 目錄層數" 在提取前, 把檔案從前往後指定層數的目錄都從提取路徑中去掉, 如果檔案包含在指定層數中, 則不被提取 .TP .BR --suffix " 字尾" 備份檔案時, 使用指定的字尾, 而不是使用預設字尾‘~’ .TP .BR -T ", " --files-from " 檔案" 從指定檔案中獲得要提取或建立的存檔的名字 .TP .BR --test-label 讀取卷標; 如果一個詞被指定了, 則測試它是否匹配這個卷標 .TP .BR --to-command " 命令" 提取期間, 將提取的檔案匯入到指定命令的標準輸入 .TP .BR --totals 顯示用--create引數寫入的總位元組數 .TP .BR --transform " sed表示式" 用\fBsed\fR的轉換表示式轉換檔案或成員的名字 .TP .BR -U ", " --unlink-first 提取檔案之前,刪除已存在的與之同名的檔案 .TP .BR --unquote 不標識輸入檔案或成員的名字; 這是預設選項 .TP .BR --utc 以UTC時間顯示檔案的修改日期 .TP .BR -v ", " --verbose 列出檔案的處理情況 .TP .BR -V ", " --label " 名稱" 用指定卷名建立存檔 .TP .BR --version 顯示\fBtar\fR程式的版本資訊 .TP .BR --volno-file " 檔案" 保持追蹤指定檔案中多卷存檔的卷編號; 和\fI--multi-volume\fR一起使用 .TP .BR -w ", " --interactive ", " --confirmation 每一個動作都要求確認 .TP .BR -W ", " --verify 寫完存檔後對其進行校驗 .TP .BR --wildcards 對\fI--exclude\fR用萬用字元 .TP .BR --wildcards-match-slash \fI--exclude\fR的萬用字元匹配斜槓(/) .TP .BR -X ", " --exclude-from " 檔案" 排除列在指定檔案中的檔案 .TP .BR -z ", " --gzip ", " --gunzip ", " --ungzip 用gzip對存檔進行操作 .TP .BR -Z ", " --compress ", " --uncompress 用compress對存檔進行操作 .TP .BR -[0-7][lmh] 指定驅動器[0-7]和壓縮密度[低中高] .SH BUGS GNU世界的人, 通常不喜歡man手冊, 而是寫文件代替之。 \fBtar\fR的維護者也是如此。 所以,\ 這個man手冊頁可能會不完全, 或者不夠新, 它被包含在Gentoo的portage樹中, 因為man是一個非常好的工具:)。 這個man手冊頁最初取自Debian\ Linux, 從那時起已在這裡被很好地更新。 .SH "報告 BUGS" 請透過 http://bugs.gentoo.org/ 報告Bug。 翻譯問題請聯絡譯者或到 https://github.com/lidaobing/manpages-zh/ 提交問題 .SH "作者" .nf Debian Linux http://www.debian.org/ Mike Frysinger .SH "譯者" .nf CMPP 中文手冊頁計劃 http://cmpp.linuxforum.net (2001/08/08) Saigut (2013/11/09) .SH "中文版最新更新" .B 2014/10/04 .fi .SH "跋" .br 本頁面中文版由中文 man 手冊頁計劃提供。 .br 中文 man 手冊頁計劃:\fBhttps://github.com/man-pages-zh/manpages-zh\fR