tar、zip、rar压缩/解压命令

参考链接:https://blog.csdn.net/weixin_43220532/article/details/116696812

压缩

tar –czf jpg.tar.gz *.jpg   将目录里所有jpg文件打包成jpg.tar后,并且将其用gzip压缩,生成一个gzip压缩过的包,命名为jpg.tar.gz

tar –cjf jpg.tar.bz2 *.jpg 将目录里所有jpg文件打包成jpg.tar后,并且将其用bzip2压缩,生成一个bzip2压缩过的包,命名为jpg.tar.bz2

tar –cZf jpg.tar.Z *.jpg   将目录里所有jpg文件打包成jpg.tar后,并且将其用compress压缩,生成一个umcompress压缩过的包,命名为jpg.tar.Z

【压缩命令】在html文件夹的当前目录 .  时候压缩

zip  -qr html.zip  ./html

root@master:~/fpi/install/06.ipes/charts/cas# zip -qr cas-config ./etc/

tar、zip、rar压缩/解压命令

参考链接:http://edu.jb51.net/linux/linux-comm-zip.html

解压

tar –xvf file.tar  解压 tar包

tar -xzvf file.tar.gz 解压tar.gz

tar -xjvf file.tar.bz2   解压 tar.bz2

tar –xZvf file.tar.Z   解压tar.Z

e 解压压缩文件到当前目录

unrar e file.rar (完全解压,不会保持原有目录,所有都解压到当前目录了)

x 用绝对路径解压文件创建文件夹:mkdir target_dir

unrar  x   $rar_file   $ext_path(会保持原有目录解压)

第一要在当前目录下创建文件夹:mkdir target_dir (要确保当前目录下存在解压文件夹)

unrar  x test.rar  ./target_dir   (会保持原有目录解压)   //把test.rar文件解压到当前目录的target_dir文件夹下

第一个参数为rar所在文件夹,第二个参数为解压路径。

tar、zip、rar压缩/解压命令

unzip 如果要把文件解压到指定的目录下,需要用到-d参数 

root@master:~/fpi#

unzip -d ./cas-config cas-config.zip

unzip -d  /temp test.zip

unzip -d ~/temp test.zip

unzip -d ./temp test.zip

unzip -d ./test11 -O CP936 data.zip  ##针对中文乱码

把文件解压到当前目录下 unzip test.zip

如果要把文件解压到指定的目录下,需要用到-d参数. unzip -d /temp test.zip

解压的时候,有时候不想覆盖已经存在的文件,那么可以加上-n参数 unzip -n test.zip unzip -n -d /temp test.zip

只看一下zip压缩包中包含哪些文件,不进行解压缩 unzip -l test.zip
root@master:~/fpi# unzip -l cas-config.zip

Archive:  cas-config.zip

  Length      Date    Time    Name

———  ———- —–  —-

        0  2022-08-15 16:46  etc/

      545  2022-05-31 15:28  etc/casGenericSuccess.jsp

    12212  2022-08-15 16:44  etc/casLoginView.jsp

    4400  2022-05-31 15:28  etc/cas.properties

    10009  2022-08-15 16:08  etc/LOGO.png

———                    ——-

    27166                    5 files

© 版权声明

相关文章

暂无评论

您必须登录才能参与评论!
立即登录
none
暂无评论...