Linux 7z,tar解压缩 使用

1.解压一个文件并解包

如图:

7z x -so -o/home/qian/coded VimLite-498.tar.bz2 |tar x –directory ~/coded

命令解释:

x eXtract with full paths (全路径解压,原有的文件,目录关系保持不变)

-soWrite data to StdOut (eg: % echo foo | 7z a dummy -tgzip -si -so > /dev/null) 把数据写到stdout,这里是tar的stdcin

-o{Directory} Set Output directory 指定解压的目录(注意:o后面没有空格,紧接着目录,可以是相对路径,可以用来新建(这里不能用~,那样会新建个~目录,东西都在里面)

VimLite-498.tar.bz2 就是要解压并解包的文件

| (暂时不知道)

tar

-x, –extract, –get extract files from an archive (从一个文档中解包)

-C, –directory DIR change to directory DIR(用来指定文件解包到的目录,这里可以用~。。。。)

2.打包并压缩

tar -c -C /home/qian/code list | 7z a -si list.tar.7z

tar:-c,–creat creat a new archive(创建一个新文档)

-C, –directory change to directory(切换目录到/home/qian/code,可以是相对目录,可以在打包或解包的时候用,打包就是打包该目录下的文件,只能打包该目录下的,若是其他的加-P absolute-names,解包就是解到该目录下)

list是要打包的目录名,可以是多个文件(空格隔开)

7z:

a add(添加到压缩文件,没有就新建)

-si Read data from StdIn (eg: tar cf – directory | 7z a -si directory.tar.7z) (从标准输入中读取数据)

list.tar.7z 目标文件名(后缀没有特定意义,只是为了区分是什么格式,是怎么打包压缩的)

参考资料:

Linux Manual

闹里有钱,静处安身。

Linux 7z,tar解压缩 使用

相关文章:

你感兴趣的文章:

标签云: