Linux解压.gz的命令是啥?

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Linux解压.gz的命令是啥?相关的知识,希望对你有一定的参考价值。

参考技术A

    解压缩命令:

    命令格式:tar  -zxvf  压缩文件名.tar.gz。解压缩后的文件只能放在当前的目录。

    解压全部命令参考:

    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

    linux下解压命令大全

    .tar

    解包:tar xvf FileName.tar

    打包:tar cvf FileName.tar DirName

    (注:tar是打包,不是压缩!)

    ———————————————

    .gz

    解压1:gunzip FileName.gz

    解压2:gzip -d FileName.gz

    压缩:gzip FileName

    .tar.gz 和 .tgz

    解压:tar zxvf FileName.tar.gz

    压缩:tar zcvf FileName.tar.gz DirName

    ———————————————

    .bz2

    解压1:bzip2 -d FileName.bz2

    解压2:bunzip2 FileName.bz2

    压缩: bzip2 -z FileName

    .tar.bz2

    解压:tar jxvf FileName.tar.bz2

    压缩:tar jcvf FileName.tar.bz2 DirName

    ———————————————

    .bz

    解压1:bzip2 -d FileName.bz

    解压2:bunzip2 FileName.bz

    压缩:未知

    .tar.bz

    解压:tar jxvf FileName.tar.bz

    压缩:未知

    ———————————————

    .Z

    解压:uncompress FileName.Z

    压缩:compress FileName

    tar.Z

    解压:tar Zxvf FileName.tar.Z

    压缩:tar Zcvf FileName.tar.Z DirName

    ———————————————

    .zip

    解压:unzip FileName.zip

    压缩:zip FileName.zip DirName

    ———————————————

    .rar

    解压:rar x FileName.rar

    压缩:rar a FileName.rar DirName

    ———————————————

    .lha

    解压:lha -e FileName.lha

    压缩:lha -a FileName.lha FileName

    ———————————————

    .rpm

    解包:rpm2cpio FileName.rpm | cpio -div

    ———————————————

    .deb

    解包:ar p FileName.deb data.tar.gz | tar zxf -

    ———————————————

    .tar .tgz .tar.gz .tar.Z .tar.bz .tar.bz2 .zip .cpio .rpm .deb .slp .arj .rar .ace .lha .lzh .lzx .lzs .arc .sda .sfx .lnx .zoo .cab .kar .cpt .pit .sit .sea

    解压:sEx x FileName.*

    压缩:sEx a FileName.* FileName

    sEx只是调用相关程序,本身并无压缩、解压功能,请注意!

    gzip 命令

    减少文件大小有两个明显的好处,一是可以减少存储空间,二是通过网络传输文件时,可以减少传输的时间。gzip 是在 Linux 系统中经常使用的一个对文件进行压缩和解压缩的命令,既方便又好用。

    语法:gzip [选项] 压缩(解压缩)的文件名该命令的各选项含义如下:

    -c 将输出写到标准输出上,并保留原有文件。-d 将压缩文件解压。-l 对每个压缩文件,显示下列字段:     压缩文件的大小;未压缩文件的大小;压缩比;未压缩文件的名字-r 递归式地查找指定目录并压缩其中的所有文件或者是解压缩。-t 测试,检查压缩文件是否完整。-v 对每一个压缩和解压的文件,显示文件名和压缩比。-num 用指定的数字 num 调整压缩的速度,-1 或 --fast 表示最快压缩方法(低压缩比),-9 或--best表示最慢压缩方法(高压缩比)。系统缺省值为 6。指令实例:

    gzip *% 把当前目录下的每个文件压缩成 .gz 文件。gzip -dv *% 把当前目录下每个压缩的文件解压,并列出详细的信息。gzip -l *% 详细显示例1中每个压缩的文件的信息,并不解压。gzip usr.tar% 压缩 tar 备份文件 usr.tar,此时压缩文件的扩展名为.tar.gz。

Linux命令linux一次性解压多个.gz或者.tar.gz文件

原文:linux一次性解压多个.gz或者.tar.gz文件

解压多个压缩包

对于解压多个.gz文件的,用此命令:

for gz in *.gz; do gunzip $gz; done

对于解压多个.tar.gz文件的,用下面命令:

for tar in *.tar.gz;  do tar xvf $tar; done

扩展:tar命令

tar [-] A --catenate --concatenate | c --create | d --diff --compare | --delete | r --append | t --list |
    --test-label | u --update | x --extract --get [options] [pathname ...]
-A, --catenate, --concatenate
      append tar files to an archive
-c, --create
      create a new archive
-d, --diff, --compare
      find differences between archive and file system
--delete
      delete from the archive (not on mag tapes!)
-r, --append
      append files to the end of an archive
-t, --list
      list the contents of an archive
--test-label
      test the archive volume label and exit
-u, --update
      only append files newer than copy in archive
-x, --extract, --get
      extract files from an archive
-a, --auto-compress
      use archive suffix to determine the compression program
--add-file=FILE
      add given FILE to the archive (useful if its name starts with a dash)
--anchored
      patterns match file name start
--no-anchored
      patterns match after any `/\' (default for exclusion)
--atime-preserve
      preserve access times on dumped files, either by restoring the times
--no-auto-compress
      do not use archive suffix to determine the compression program
-b, --blocking-factor BLOCKS
      BLOCKS x 512 bytes per record
-B, --read-full-records
      reblock as we read (for 4.2BSD pipes)
--backup
      backup before removal, choose version CONTROL
-C, --directory DIR
      change to directory DIR
--check-device
      check device numbers when creating incremental archives (default)
--no-check-device
      do not check device numbers when creating incremental archives
--checkpoint
      display progress messages every NUMBERth record (default 10)
--checkpoint-action=ACTION
      execute ACTION on each checkpoint
--delay-directory-restore
      delay setting modification times and permissions of extracted
--no-delay-directory-restore
      cancel the effect of --delay-directory-restore option
--exclude=PATTERN
      exclude files, given as a PATTERN
--exclude-backups
      exclude backup and lock files
--exclude-caches
      exclude contents of directories containing CACHEDIR.TAG,
--exclude-caches-all
      exclude directories containing CACHEDIR.TAG
--exclude-caches-under
      exclude everything under directories containing CACHEDIR.TAG
--exclude-tag=FILE
      exclude contents of directories containing FILE, except
--exclude-tag-all=FILE
      exclude directories containing FILE
--exclude-tag-under=FILE
      exclude everything under directories containing FILE
--exclude-vcs
      exclude version control system directories
-f, --file ARCHIVE
      use archive file or device ARCHIVE
-F, --info-script, --new-volume-script NAME
      run script at end of each tape (implies -M)
--force-local
      archive file is local even if it has a colon
--full-time
      print file time to its full resolution
-g, --listed-incremental FILE
      handle new GNU-format incremental backup
-G, --incremental
      handle old GNU-format incremental backup
--group=NAME
      force NAME as group for added files
-h, --dereference
      follow symlinks; archive and dump the files they point to
-H, --format FORMAT
      create archive of the given formatFORMAT is one of the following:
--format=gnu
      GNU tar 1.13.x format
--format=oldgnu
      GNU format as per tar <= 1.12
--format=pax
      POSIX 1003.1-2001 (pax) format
--format=posix
      same as pax
--format=ustar
      POSIX 1003.1-1988 (ustar) format
--format=v7
      old V7 tar format
--hard-dereference
      follow hard links; archive and dump the files they refer to
-i, --ignore-zeros
      ignore zeroed blocks in archive (means EOF)
-I, --use-compress-program PROG
      filter through PROG (must accept -d)
--ignore-case
      ignore case
--no-ignore-case
      case sensitive matching (default)
--ignore-command-error
      ignore exit codes of children
--no-ignore-command-error
      treat non-zero exit codes of children as error
--ignore-failed-read
      do not exit with nonzero on unreadable files
--index-file=FILE
      send verbose output to FILE
-j, --bzip2
-J, --xz
-k, --keep-old-files
      don\'t replace existing files when extracting
-K, --starting-file MEMBER-NAME
      begin at member MEMBER-NAME in the archive
--keep-newer-files
      don\'t replace existing files that are newer than their archive copies
-l, --check-links
      print a message if not all links are dumped
-L, --tape-length NUMBER
      change tape after writing NUMBER x 1024 bytes
--level=NUMBER
      dump level for created listed-incremental archive
--lzip
--lzma
--lzop
-m, --touch
      don\'t extract file modified time
-M, --multi-volume
      create/list/extract multi-volume archive
--mode=CHANGES
      force (symbolic) mode CHANGES for added files
--mtime=DATE-OR-FILE
      set mtime for added files from DATE-OR-FILE
-n, --seek
      archive is seekable
-N, --newer, --after-date DATE-OR-FILE
      only store files newer than DATE-OR-FILE
--newer-mtime=DATE
      compare date and time when data changed only
--null
      -T reads null-terminated names, disable -C
--no-null
      disable the effect of the previous --null option
--numeric-owner
      always use numbers for user/group names
-O, --to-stdout
      extract files to standard output
--occurrence
      process only the NUMBERth occurrence of each file in the archive;
--old-archive, --portability
      same as --format=v7
--one-file-system
      stay in local file system when creating archive
--overwrite
      overwrite existing files when extracting
--overwrite-dir
      overwrite metadata of existing directories when extracting (default)
--no-overwrite-dir
      preserve metadata of existing directories
--owner=NAME
      force NAME as owner for added files
-p, --preserve-permissions, --same-permissions
      extract information about file permissions (default for superuser)
-P, --absolute-names
      don\'t strip leading `/\'s from file names
--pax-option=keyword[[:]=value][,keyword[[:]=value]]...
      control pax keywords
--posix
      same as --format=posix
--preserve
      same as both -p and -s
--quote-chars=STRING
      additionally quote characters from STRING
--no-quote-chars=STRING
      disable quoting for characters from STRING
--quoting-style=STYLE
      set name quoting style; see below for valid STYLE values
-R, --block-number
      show block number within archive with each message
--record-size=NUMBER
      NUMBER of bytes per record, multiple of 512
--recursion
      recurse into directories (default)
--no-recursion
      avoid descending automatically in directories
--recursive-unlink
      empty hierarchies prior to extracting directory
--remove-files
      remove files after adding them to the archive
--restrict
      disable use of some potentially harmful options
--rmt-command=COMMAND
      use given rmt COMMAND instead of rmt
--rsh-command=COMMAND
      use remote COMMAND instead of rsh
-s, --preserve-order, --same-order
      sort names to extract to match archive
-S, --sparse
      handle sparse files efficiently
--same-owner
      try extracting files with the same ownership as exists in the archive (default for superuser)
--no-same-owner
      extract files as yourself (default for ordinary users)
--no-same-permissions
      apply the user\'s umask when extracting permissions from the archive (default for ordinary users)
--no-seek
      archive is not seekable
--show-defaults
      show tar defaults
--show-omitted-dirs
      when listing or extracting, list each directory that does not match search criteria
--show-transformed-names, --show-stored-names
      show file or archive names after transformation
--sparse-version=MAJOR[.MINOR]
      set version of the sparse format to use (implies --sparse)
--strip-components=NUMBER
      strip NUMBER leading components from file names on extraction
--suffix=STRING
      backup before removal, override usual suffix (\'~\' unless overridden by environment variable
      SIMPLE_BACKUP_SUFFIX)
-T, --files-from FILE
      get names to extract or create from FILE
--to-command=COMMAND
      pipe extracted files to another program
--totals
      print total bytes after processing the archive;
--transform, --xform EXPRESSION
      use sed replace EXPRESSION to transform file names
-U, --unlink-first
      remove each file prior to extracting over it
--unquote
      unquote filenames read with -T (default)
--no-unquote
      do not unquote filenames read with -T
--utc
      print file modification times in UTC
-v, --verbose
      verbosely list files processed
-V, --label TEXT
      create archive with volume name TEXT; at list/extract time, use TEXT as a globbing pattern for volume
      name
--volno-file=FILE
      use/update the volume number in FILE
-w, --interactive, --confirmation
      ask for confirmation for every action
-W, --verify
      attempt to verify the archive after writing it
--warning=KEYWORD
      warning control
--wildcards
      use wildcards (default for exclusion)
--wildcards-match-slash
      wildcards match `/\' (default for exclusion)
--no-wildcards-match-slash
      wildcards do not match `/\'
--no-wildcards
      verbatim string matching
-X, --exclude-from FILE
      exclude patterns listed in FILE
-z, --gzip, --gunzip --ungzip
-Z, --compress, --uncompress

以上是关于Linux解压.gz的命令是啥?的主要内容,如果未能解决你的问题,请参考以下文章

linux命令中tar后跟的zxvf是啥意思

linux 命令中tar后跟的zxvf是啥意思呢?每次解压文件都需要用到,没有的话还无法进行?

linux命令中tar后跟的zxvf是啥意思?

java调用linux命令解压gz

急求解压ramdisk.image.gz命令

Linux命令linux一次性解压多个.gz或者.tar.gz文件