#Linux 压缩与解压缩命令总结

时间:2023-02-07 18:47:52

Linux 压缩与解压缩命令总结


Content:

=======

RAR

rar压缩

命令如下:rar command -switch 1 -switch N archive files.rar @listfiles…
example:

cj@abigail ~/rardemo> rar a -rr10 demo demo2 dt
Creating archive demo.rar
Adding demo2 OK
Adding dt OK
Adding data recovery record
Done

command

a为adding,添加文件。

switch

-rr10为添加恢复记录。
此外常用的switch还有:

  • -r :将./目录下所有文件都添加到压缩文件中去。

  • -mN :n为1-5,按mN的压缩比进行压缩。默认为m3,最高为m5。

  • -s :指定生成的文件路径和位置:rar a -s ../demo2.rar file1 file2

编写rarlist批量压缩

example:

cj@abigail ~/rardemo> cat rarlist 
./demo2
./dt
cj@abigail ~/rardemo> rar a demo @rarlist
Creating archive demo.rar

Adding ./demo2 OK
Adding ./dt OK
Done
cj@abigail ~/rardemo> ls
demo2 demo.rar dt rarlist test2

unrar解压缩

命令如下:unrar command -switch 1 -switch N archive files… @listfiles… path_to_extract\
example:

cj@abigail ~/rardemo> ls
demo2 demo.rar dt rarlist test2
cj@abigail ~/rardemo> unrar x demo.rar test/

UNRAR 5.21 freeware Copyright (c) 1993-2015 Alexander Roshal


Extracting from demo.rar

Creating test OK
Extracting test/demo2 OK
Extracting test/dt OK
All OK
cj@abigail ~/rardemo> ls
demo2 demo.rar dt rarlist test/ test2

switch可参考rar.
Details:Archwiki

tar :tape archiver

tar只是一个打包命令。

Examples:
tar -cf archive.tar foo bar # Create archive.tar from files foo and bar.
tar -tvf archive.tar # List all files in archive.tar verbosely.
tar -xf archive.tar # Extract all files from archive.tar.

tar.gz,tar.xz,tar.bz2

-j, –bzip2 filter the archive through bzip2
-J, –xz filter the archive through xz
-z, –gzip, –gunzip, –ungzip filter the archive through gzip

其实也就是tar命令进行打包或者解包,此时在加上过滤-z/j,之后会对齐进行处理。
example:

cj@abigail ~/rardemo> ls
demo2 dt rarlist test/ test2 v z
cj@abigail ~/rardemo> tar -zcf demo.tar.gz demo2 dt rarlist
cj@abigail ~/rardemo> ls
demo2 demo.tar.gz dt rarlist test/ test2 v z
cj@abigail ~/rardemo> tar -zxf demo.tar.gz
cj@abigail ~/rardemo> ls
demo2 demo.tar.gz dt rarlist test/ test2 v z
cj@abigail ~/rardemo> gunzip -d demo.tar.gz
cj@abigail ~/rardemo> ls
demo2 demo.tar dt rarlist test/ test2 v z
ps:f要写在最后,f指定压缩包名,放前面会报错。