bzip2

What is the difference between incremental and one-shot compression?

和自甴很熟 提交于 2019-12-01 08:00:41
问题 I am trying to use the bz2 and/or lzma packages in python. I am trying to compress a database dump in csv format and then put it to a zip file. I got it to work with one-shot compression with both the packages. Code for which looks like this: with ZipFile('something.zip', 'w') as zf: content = bz2.compress(bytes(csv_string, 'UTF-8')) # also with lzma zf.writestr( 'something.csv' + '.bz2', content, compress_type=ZIP_DEFLATED ) When I try to use incremental compression then it creates a .zip

Bzip2 block header: 1AY&SY

谁说胖子不能爱 提交于 2019-12-01 07:49:56
问题 This is the question about bzip2 archive format. Any Bzip2 archive consists of file header, one or more blocks and tail structure. All blocks should start with "1AY&SY", 6 bytes of BCD-encoded digits of the Pi number, 0x314159265359. According to the source of bzip2: /*-- A 6-byte block header, the value chosen arbitrarily as 0x314159265359 :-). A 32 bit value does not really give a strong enough guarantee that the value will not appear by chance in the compressed datastream. Worst-case

20.zip压缩工具 tar打包 打包并压缩

半腔热情 提交于 2019-11-30 12:21:07
1.tar tar命令格式 [-zjxcvfpP] filename tar -z:表示同时用gzip压缩。 -j:表示同时用bzip2压缩。 -J:表示同时用xz压缩。 -x:表示解包或者解压缩。 -t:表示查看tar包里的文件。 -c:表示建立一个tar包或者压缩文件包。 -v:表示可视化。 -f:后面跟文件名(即-f filename,表示压缩后的文件名为filename,或者解压文件filename。多个参数组合的情况下,请把-f参数写到最后。) -P:表示使用原文件的属性。(不常用) -p:表示可以使用绝对路径。(不常用) --exclude filename:表示在打包或压缩时,不要将filename文件包括在内。(不常用) [root@localhost ~]# cd test -bash: cd: test: 没有那个文件或目录 [root@localhost ~]# cd /tmp/8/test [root@localhost test]# xz -d 1.txt.xz xz: 1.txt.xz: 没有那个文件或目录 [root@localhost test]# ls 1.txt [root@localhost test]# xz -z 1.txt.xz xz: 1.txt.xz: 没有那个文件或目录 [root@localhost test]# xz -z 1

19.压缩打包介绍 gip压缩工具 bzip压缩工具 xz压缩工具

喜夏-厌秋 提交于 2019-11-30 12:20:21
1.linux下常见的后缀名所对应的压缩工具。 .gz:表示由gzip压缩工具压缩的文件。 .bz:表示由bzip2压缩工具压缩的文件。 .tar:表示由tar打包程序打包的文件。 .tar.gz:先由tar打包,再由gzip压缩。 .tar.bz2:先由tar打包,再由bgzip压缩。 .tar.bz2:先由tar打包,再由xz压缩。 2.gip压缩工具 gizp命令格式为gizap [-d#] filename 其中#为1-9的数字。 -d:解压缩时使用。 -#:表示压缩等级,1为最差,9为最好,6为默认。 [root@bogon ~]# mkdir /tmp/8 [root@bogon ~]# cd /tmp/8 [root@bogon 8]# mkdir test [root@bogon 8]# mv /tmp/1.txt test [root@bogon 8]# cd test [root@bogon test]# ls 1.txt [root@bogon test]# gzip 1.txt [root@bogon test]# ls 1.txt.gz gzip后面跟文件名,表示在当前目录下压缩该文件,而元文件也会消失。 解压缩命令: [root@bogon test]# gzip -d 1.txt.gz [root@bogon test]# ls 1.txt gzip

Linux系统信息相关、其他命令(五)

…衆ロ難τιáo~ 提交于 2019-11-30 07:04:15
系统信息相关命令 本结是为了方便通过远程终端维护服务器时,查看服务器上当前系统日期和时间、磁盘空间占用情况、程序执行情况 本结基本都是查询命令,通过这些命令对系统资源的使用情况有个了解 目标 时间和日期 date 查看系统时间 cal calendar 查看日历 -y 选项可以查看一年的日历 磁盘和目录空间 df disk free 显示磁盘剩余空间 du -h [目录名] disk usage 显示目录下的文件大小 -h 以人性化的方式显示文件大小 进程信息 所谓进程,通俗讲就是正在执行的一个程序 ps aux process status 查看进程的详细状况,默认只会显示当前用户通过终端启动的应用程序 a 显示终端上的所有进程,包括其他用户的进程 u 显示进程的详细状态 x 显示没有控制终端的进程 top 动态显示运行程序并且排序 要退出top命令,输入小写q kill [-9] 进程代号 终止指定代号的进程 -9 表示强行终止 ps:使用kill命令时,最好只终止由当前用户开启的进程,而不要终止root身份开启的进程,否则可能导致系统崩溃 其他命令 查找文件 find 功能非常强大,通常用来在特定的目录下搜索符合条件的文件 find [路径] -name "*.py" 查找指定路径下扩展名是.py的文件,包括子目录 如果省略路径,表示在当前文件夹下查找 通配符

Linux下的t压缩解压缩命令

浪尽此生 提交于 2019-11-29 17:10:16
tar -c: 建立压缩档案 -x:解压 -t:查看内容 -r:向压缩归档文件末尾追加文件 -u:更新原压缩包中的文件 这五个是独立的命令,压缩解压都要用到其中一个,可以和别的命令连用但只能用其中一个。下面的参数是根据需要在压缩或解压档案时可选的。 -z:有gzip属性的 -j:有bz2属性的 -Z:有compress属性的 -v:显示所有过程 -O:将文件解开到标准输出 下面的参数-f是必须的 -f: 使用档案名字,切记,这个参数是最后一个参数,后面只能接档案名。 # tar -cf all.tar *.jpg 这条命令是将所有.jpg的文件打成一个名为all.tar的包。-c是表示产生新的包,-f指定包的文件名。 # tar -rf all.tar *.gif 这条命令是将所有.gif的文件增加到all.tar的包里面去。-r是表示增加文件的意思。 # tar -uf all.tar logo.gif 这条命令是更新原来tar包all.tar中logo.gif文件,-u是表示更新文件的意思。 # tar -tf all.tar 这条命令是列出all.tar包中所有文件,-t是列出文件的意思 # tar -xf all.tar 这条命令是解出all.tar包中所有文件,-t是解开的意思 压缩 tar -cvf jpg.tar *.jpg //将目录里所有jpg文件打包成tar

Linux压缩好帮手bzip2

心不动则不痛 提交于 2019-11-29 17:09:44
导读 对文件进行压缩,可以通过使用较少的字节对文件中的数据进行编码来显著地减小文件的大小,并且在跨网络的文件的备份和传送时很有用。 另一方面,解压文件意味着将文件中的数据恢复到初始状态。 Linux 中有几个文件压缩和解压缩工具,比如gzip、7-zip、Lrzip、PeaZip 等等。 本篇教程中,我们将介绍如何在 Linux 中使用 bzip2 工具压缩及解压缩.bz2文件。 bzip2 是一个非常有名的压缩工具,并且在大多数主流 Linux 发行版上都有,你可以在你的发行版上用合适的命令来安装它。 $ sudo apt install bzip2 [On Debian/Ubuntu] $ sudo yum install bzip2 [On CentOS /RHEL] $ sudo dnf install bzip2 [On Fedora 22+] 使用 bzip2 的常规语法是: $ bzip2 option(s) filenames 如何在 Linux 中使用“bzip2”压缩文件 你可以如下压缩一个文件,使用-z标志启用压缩: $ bzip2 filename 或者 $ bzip2 -z filename 要压缩一个.tar文件,使用的命令为: $ bzip2 -z backup.tar 重要:bzip2 默认会在压缩及解压缩文件时删除输入文件(原文件),要保留输入文件

How to compress a directory with libbz2 in C++

流过昼夜 提交于 2019-11-29 09:49:23
I need to create a tarball of a directory and then compress it with bz2 in C++. Is there any decent tutorial on using libtar and libbz2? Matthew Flaschen Okay, I worked up a quick example for you. No error checking and various arbitrary decisions, but it works. libbzip2 has fairly good web documentation . libtar, not so much, but there are manpages in the package, an example, and a documented header file. The below can be built with g++ C++TarBz2.cpp -ltar -lbz2 -o C++TarBz2.exe : #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <stdlib.h> #include <libtar.h> #include

压缩打包介绍,gzip压缩工具,bzip2压缩工具,xz压缩工具,zip压缩工具,tar打包,打包并压缩

纵饮孤独 提交于 2019-11-29 09:41:20
压缩打包介绍 由于网络资源是有限的,机房服务器带宽非常昂贵 怎样用合理的使用带宽是很重要的 将文件压缩后,无论是存储还是传输,既节省服务器空间,又节省带宽 上图是目前主要的压缩格式 在linux里面,虽然不像windows一样,文件后缀名有严格限制 不管什么格式的文件,都可以自定义文件后缀 但是这样不利于管理,也不方便与他人沟通交流使用 所以还是应该按照文件内容正确的格式来命名文件后缀 gzip 压缩工具 gzip是linux的一种压缩工具 从上图可以看到,有一个叫做 1.txt 的文件,文件大小是3.1MB,有37860行 现在使用 gzip 对1.txt进行压缩 压缩命令就是 gzip 1.txt 回车就完成了 然后使用 ls 查看当前目录 1.txt文件消失了,出现了一个新的文件,叫做 1.txt.gz 源文件被压缩后并重命名为了 1.txt.gz 如上图,使用 gzip -d 1.txt.gz 命令把 1.txt.gz 文件进行了解压缩 加上 -d 参数就可以对文件进行解压缩 下面使用 ls 查看目录,发现 1.txt.gz 不见了,1.txt 又出现了 1.txt.gz 被解压缩并重命名为了 1.txt 解压缩后查看文件大小,发现只有 1.4MB ,压缩前有 3MB 左右 因为原来的文件占用了很多虚的空间,压缩之后就把这些虚的空间消除掉了

Only decompress a specific bzip2 block

冷暖自知 提交于 2019-11-29 08:38:03
问题 Say I have a bzip2 file (over 5GB), and I want to decompress only block #x, because there is where my data is (block is different every time). How would I do this? I thought about making an index of where all the blocks are, then cut the block I need from the file and apply bzip2recover to it. I also thought about compressing say 1MB at a time, then appending this to a file (and recording the location), and simply grabbing the file when I need it, but I'd rather keep the original bzip2 file