首先,看下man tar:
NAME
tar - The GNU version of the tape archiver (tar) utilitySYNOPSIS
tar <operation> [options]
Operations:
[-]A --catenate --concatenate
[-]c --create(打包文件)
[-]d --diff --compare
[-]r --append(追加)
[-]t --list(列出)
[-]u --update(更新)
[-]x --extract --get(解压缩)
--delete
Common Options:
-C, --directory DIR
-f, --file FILE
-j, --bzip2
-J, --xz
-p, --preserve-permissions
-v, --verbose( 详细)
-z, --gzip
常用命令:
1.打包文件:
tar -cf test.zip test
这条命令是把当前目录下的test文件打包成test.zip
tar -uf all.tar logo.gif
这条命令是更新原来tar包all.tar中logo.gif文件,-u是表示更新文件的意思。
2.解压缩文件:
tar -zvxf test.zip