参考链接:https://blog.csdn.net/weixin_43220532/article/details/116696812
压缩
tar –cvf jpg.tar *.jpg 将目录里所有jpg文件打包成tar.jpg
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/
参考链接: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
unrar e file.rar 解压rar
unrar x $rar_file $ext_path
unrar x test.rar test33 //把test.rar文件解压到当前目录的test33文件夹下
第一个参数为rar所在文件夹,第二个参数为解压路径。
如果要把文件解压到指定的目录下,需要用到-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 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.zipArchive: 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
网友评论