Linuxでのtar圧縮解凍コマンドの詳細

13937 ワード

tar
-c:圧縮ファイルの作成-x:解凍-t:表示内容-r:圧縮アーカイブファイルの末尾にファイルを追加-u:元の圧縮パッケージのファイルを更新
この5つは独立したコマンドで、圧縮解凍はいずれも1つを使用し、他のコマンドと連用することができますが、そのうちの1つしか使用できません.次のパラメータは、必要に応じてファイルを圧縮または解凍する場合に選択できます.-z:gzip属性を持つ-j:bz 2属性を持つ-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後、それをbzip 2で圧縮する、bzip 2で圧縮されたパケットをjpgと命名する.tar.bz2
tar -cZf jpg.tar.Z *.jpg//ディレクトリ内のすべてのjpgファイルをjpgにパッケージする.tar後、compressで圧縮する、jpgという名前のumcompress圧縮パケットを生成する.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.bz 2//解凍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、*.bz 2はbzip 2-dまたはbunzip 2で解凍する
5、*.tar.bz 2は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
root@ubuntu:~# tar --help
  : tar [  ...] [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                      
  -d, --diff, --compare                  
      --delete                  (   !)   
  -r, --append                        
  -t, --list                       
      --test-label                    
  -u, --update                             
  -x, --extract, --get               

      :

      --check-device                      (  )
  -g, --listed-incremental=FILE         GNU        
  -G, --incremental                GNU        
      --ignore-failed-read
                                              
      --level=NUMBER                        
  -n, --seek                      
      --no-check-device                     
      --no-seek                    
      --occurrence[=NUMBER]               NUMBER
                                ;         --delete,
                             --diff, --extract    --list
                                      ,      。                     
                             -T      ;NUMBER      1
      --sparse-version=MAJOR[.MINOR]
                                        (  
                             --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                
      --one-top-level[=DIR]  create a subdirectory to avoid having loose files
                             extracted
      --overwrite                      
      --overwrite-dir                      (  )

      --recursive-unlink                  
      --remove-files                      
      --skip-old-files       don't replace existing files when extracting,
                             silently skip over them
  -U, --unlink-first                         
  -W, --verify                          

      :

      --ignore-command-error           
      --no-ignore-command-error
                                              
  -O, --to-stdout                     
      --to-command=COMMAND
                                               

       :

      --atime-preserve[=METHOD]
                                          ,       (  
                             METHOD=‘replace’)     ,         (METHOD=‘system’)    
      --clamp-mtime          only set time when the file is more recent than
                             what was given with --mtime
      --delay-directory-restore
                                                  
      --group=               NAME
                                          
      --mode=CHANGES                  (  )     
                             CHANGES
      --mtime=DATE-OR-FILE     DATE-OR-FILE          
                             mtime
  -m, --touch                           
      --no-delay-directory-restore
                                --delay-directory-restore      
      --no-same-owner
                                      (        )
      --no-same-permissions
                                              (         )
      --numeric-owner                 /    
      --owner=               NAME
                                         
  -p, --preserve-permissions, --same-permissions
                                     (          )
      --preserve               -p   -s   
      --same-owner
                                           (        )
  -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

        :

  -f, --file=ARCHIVE                 ARCHIVE   
      --force-local
                                                  
  -F, --info-script=  , --new-volume-script=  
                                        (   -M)
  -L, --tape-length=NUMBER      NUMBER × 1024        
  -M, --multi-volume           /  /        
      --rmt-command=COMMAND        rmt COMMAND    rmt
      --rsh-command=COMMAND       COMMAND    rsh
      --volno-file=FILE        /   FILE     

     :

  -b, --blocking-factor=BLOCKS        BLOCKS x 512   
  -B, --read-full-records           (   4.2BSD     )
  -i, --ignore-zeros                   (     )
      --record-size=NUMBER            NUMBER,   512

       :

  -H, --format=FORMAT                 

 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=   [[:]= ][,   [[:]= ]]...
                                pax    
      --posix                    --format=posix
  -V, --label=TEXT                  TEXT
                                ;   /   ,   TEXT
                                     

     :

  -a, --auto-compress                      
  -I, --use-compress-program=PROG
                                PROG   (       -d
                                  )
  -j, --bzip2                   bzip2     
  -J, --xz                      xz     
      --lzip                    lzip     
      --lzma                    xz     
      --lzop                    xz     
      --no-auto-compress                    
  -z, --gzip, --gunzip, --ungzip      gzip     
  -Z, --compress, --uncompress      compress     

       :

      --add-file=FILE              FILE    (      -
                                    )
      --backup[=CONTROL]           ,   CONTROL   
  -C, --directory=DIR              DIR
      --exclude=PATTERN          PATTERN      
      --exclude-backups              
      --exclude-caches               ,    
                             CACHEDIR.TAG        
      --exclude-caches-all        CACHEDIR.TAG    
      --exclude-caches-under      CACHEDIR.TAG
                                     
      --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
                                    
      --exclude-tag-all=FILE      FILE    
      --exclude-tag-under=FILE        FILE          
      --exclude-vcs                    
      --exclude-vcs-ignores  read exclude patterns from the VCS ignore files
  -h, --dereference
                                   ;              
      --hard-dereference
                                  ;              
  -K, --starting-file=MEMBER-NAME
                             begin at member MEMBER-NAME when reading the
                             archive
      --newer-mtime=DATE                    
      --no-null                       --null   
      --no-recursion                   
      --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                     
  -P, --absolute-names       don't strip leading '/'s from file names
      --recursion                (  )
      --suffix=STRING              ,       
                             SIMPLE_BACKUP_SUFFIX
                               ,        (‘’)
  -T, --files-from=FILE        FILE
                                           
      --unquote              unquote input file or member names (default)
  -X, --exclude-from=FILE       FILE        

      :

      --strip-components=NUMBER              NUMBER
                                  
      --transform=EXPRESSION, --xform=EXPRESSION
                                sed    EXPRESSION
                                     

        (            ):

      --anchored                       
      --ignore-case               
      --no-anchored          patterns match after any '/' (default for
                             exclusion)
      --no-ignore-case            (  )
      --no-wildcards                
      --no-wildcards-match-slash   wildcards do not match '/'
      --wildcards                 (    exclusion )
      --wildcards-match-slash   wildcards match '/' (default for exclusion)

      :

      --checkpoint[=NUMBER]     NUMBER
                                      (    10  )
      --checkpoint-action=ACTION             ACTION
      --full-time                       
      --index-file=FILE               FILE
  -l, --check-links
                                              
      --no-quote-chars=STRING        STRING      
      --quote-chars=STRING      STRING         
      --quoting-style=STYLE          ;    STYLE
                                     
  -R, --block-number                      
      --show-defaults           tar     
      --show-omitted-dirs
                                   ,              
      --show-snapshot-field-ranges
                             show valid ranges for snapshot-file fields
      --show-transformed-names, --show-stored-names
                                          
      --totals[=SIGNAL]                  ;  
                             SIGNAL         -
                                   ;      :
                             SIGHUP,SIGQUIT,SIGINT,SIGUSR1  
                             SIGUSR2;        SIG
                                    
      --utc                    UTC           
  -v, --verbose                        
      --warning=KEYWORD          :
  -w, --interactive, --confirmation
                                      

      :

  -o                              ,   
                             --old-archive;     ,   
                             --no-same-owner

     :

  -?, --help                        
      --restrict                          
      --usage                         
      --version                    

                       。

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         :

  literal
  shell
  shell-always
  c
  c-maybe
  escape
  locale
  clocale

  tar    :
--format=gnu -f- -b20 --quoting-style=escape --rmt-command=/usr/lib/tar/rmt
--rsh-command=/usr/bin/rsh