Skip to content

Instantly share code, notes, and snippets.

@ayuLiao
Last active November 3, 2018 09:00
Show Gist options
  • Select an option

  • Save ayuLiao/13af24a096747d712c36b6cc2af2b896 to your computer and use it in GitHub Desktop.

Select an option

Save ayuLiao/13af24a096747d712c36b6cc2af2b896 to your computer and use it in GitHub Desktop.
压缩、解压单文件或多文件
tar命令可以用来压缩打包单文件、多个文件、单个目录、多个目录。
常用格式:
单个文件压缩打包 tar czvf my.tar.gz file1
多个文件压缩打包 tar czvf my.tar.gz file1 file2,...(file*)(也可以给file*文件mv 目录在压缩)
单个目录压缩打包 tar czvf my.tar.gz dir1
多个目录压缩打包 tar czvf my.tar.gz dir1 dir2
解包至当前目录:tar xzvf my.tar.gz
将 /home/html/ 这个目录下所有文件和文件夹打包为当前目录下的 html.zip:
zip -q -r html.zip /home/html
从压缩文件 cp.zip 中删除文件 a.c
zip -dv cp.zip a.c
unzip -o -d /home/sunny myfile.zip
把myfile.zip文件解压到 /home/sunny/
-o:不提示的情况下覆盖文件;
-d:-d /home/sunny 指明将文件解压缩到/home/sunny目录下;
tar -jxvf gcc-4.8.0.tar.bz2
解压tar.bz2结尾的包
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment