gzip
Usage: gzip [OPTION]... [FILE]...
Compress or uncompress FILEs (by default, compress FILES in-place).
Mandatory arguments to long options are mandatory for short options too.
-c, --stdout write on standard output, keep original files unchanged
-d, --decompress decompress
-f, --force force overwrite of output file and compress links
-h, --help give this help
-l, --list list compressed file contents
-L, --license display software license
-n, --no-name do not save or restore the original name and time stamp
-N, --name save or restore the original name and time stamp
-q, --quiet suppress all warnings
-r, --recursive operate recursively on directories
-S, --suffix=SUF use suffix SUF on compressed files
-t, --test test compressed file integrity
-v, --verbose verbose mode
-V, --version display version number
-1, --fast compress faster
-9, --best compress better
--rsyncable Make rsync-friendly archive
With no FILE, or when FILE is -, read standard input.
qq 資料夾下的檔案
$ ls qq
c.txt d.txt f.txt q.txt
壓縮資料夾
$ gzip -r qq
$ ls qq
c.txt.gz d.txt.gz f.txt.gz q.txt.gz
壓縮單檔
$ gzip qq.log
$ ls
$ qq.log.gz
解壓縮
$ gzip -rd qq
$ ls qq
c.txt d.txt f.txt q.txt
gzip僅能壓縮單一檔案
tar
- -z, –gzip, –gunzip, –ungzip filter the archive through gzip
- -v, –verbose verbosely list files processed
- -f, –file=ARCHIVE use archive file or device ARCHIVE
壓縮 qq 資料夾成 qq.tar.gz
tar -zcv -f qq.tar.gz qq
-c, –create create a new archive
查看 qq.tar.gz 裡有哪些檔案
tar -ztv -f qq.tar.gz
-t, –list list the contents of an archive
解壓縮 qq.tar.gz
tar -zxv -f qq.tar.gz
-x, –extract, –get extract files from an archive
解壓縮到 /tmp
tar -zxv -f qq.tar.gz -C /tmp
qq/
qq/d.txt
qq/c.txt
qq/f.txt
qq/q.txt
- -C, –directory=DIR change to directory DIR
- 原本的qq目錄也還會在
exclude 忽略檔案或資料夾
tar -zcv -f test.tar.gz test --exclude '.git*' --exclude 'cli.php'
忽略 .git 及 cli.php
gunzip
解壓縮 .gz
的檔案
gunzip access.log-20170725.gz
解壓縮 .zip 無法使用 tar
或 gzip
來解壓縮
必須使用 zip / unzip 做
安裝 :
sudo apt-get install zip unzip
解壓縮 :
unzip weibo-phpsdk-v2-2013-02-20.zip -d qq
解壓縮並放在 qq 資料夾裡, 如果不加上 -d qq
檔案就會散落在目前資料夾
壓縮 :
zip -r qq.zip qq
- 將 qq 資料夾壓縮成 qq.zip
-r
: recurse into directories