Linux 常用压缩解压命令
压缩、解压是日常电脑操作中常用的工具,Windows 平台之下,似乎并没有太多的学问,大多数人用一款破解的 WinRAR 全部搞定,开源爱好者可能会选择 7Zip,而熟练操作 Total Commander 的高手,用其内置的 压缩/解压 工具即可。
本文主要记录 Linux 平台下常用的 压缩/解压 命令,作为日常安装软件时的速查手册,深入分析就没有了。
别小看了压缩,水很深,比如 LZMA2 算法。更多压缩的学问,以后还会保持关注。
##1.tar
##2.zip
##3.option
c – create a new archive
v – verbosely list files which are processed.
f – following is the archive file name
z – filter the archive through gzip
j – filter the archive through bzip2
x – extract files from archive
##4.note
-
.tgz is same as .tar.gz
-
.tbz and .tb2 is same as .tar.bz2
-
In all the above commands v is optional, which lists the file being processed
-
View the tar archive file content without extracting using option tvf
##5. ext
1 ). Extract a single file
$ tar xvf archive_file.tar /path/to/file
2 ). Extract a single directory or multiple directories
$ tar xvf archive_file.tar /path/to/dir/
$ tar xvf archive_file.tar /path/to/dir1/ /path/to/dir2/
3 ). Extract group of files from archives using regular expression
$ tar xvf archive_file.tar –wildcards '*.pl'
4 ). Adding a file or directory to an existing archive using option -r
$ tar rvf archive_name.tar newfile
$ tar rvf archive_name.tar newdir/
Note: You cannot add file or directory to a compressed archive.
5 ). Subsection compression
tar cvzpf - somedir | split -b 500m
cat x* > somedir.tar.gz
全文完。
blog comments powered by Disqus