tar

zip the folder using built-in modules

感情迁移 提交于 2019-12-14 02:00:42
问题 Edit -> Can someone suggest edits to my answer, for instance I'm not sure if exec is better or spawn ? Is it possible to zip the directory/folder with it's contents using zlib and other built-in modules? I'm looking for a way to do it without external dependencies. The other option is to run local processes on mac, windows etc. for zip, tar etc., I'm sure there are command line utilities on either of the operating system This is not an answer but it's somehow related to what I'm looking for,

云服务器怎么解压文件

风格不统一 提交于 2019-12-13 21:05:24
我们在使用云服务器的过程中,经常涉及到文件的解压缩,这里我们以Linux系统为例,下面宵云小编介绍下云服务器怎么解压文件。 一、zip格式 zip可能是目前使用的最多的文档压缩格式。它最大的优点就是在不同的操作系统平台上使用。缺点就是支持的压缩率不是很高,而tar.gz和tar.bz2在压缩率方面做得非常好。 我们可以使用下列的命令压缩一个文件: zip -r archive_name.zip filename (-r是压缩文件) 下面是如果解压一个zip文件: unzip archive_name.zip (解压文件在当前文件下) unzip archive_name.zip -d new_dir (解压文件可以将文件解压缩至一个你指定的的目录,使用-d参数) 二、tar格式 tar是在Linux中使用得非常广泛的文档打包格式。它的好处就是它只消耗非常少的CPU以及时间去打包文件,它仅仅只是一个打包工具,并不负责压缩。下面是如何打包一个目录: tar -cvf archive_name.tar directory_to_compress -c参数是建立新的存档 -v参数详细显示处理的文件 -f参数指定存档或设备 打包之后如何解包: tar -xvf archive_name.tar 上面这个解包命令将会将文档解开在当前目录下面。当然,你也可以用下面的这个命令来解包到指定的路径:

bash: extract only part of tar.gz archive

有些话、适合烂在心里 提交于 2019-12-13 19:15:36
问题 I have a very large .tar.gz file which I can't extract all together because of lack of space . I would like to extract half of its contents, process them, and then extract the remaining half. The archive contains several subdirectories, which in turn contain files. When I extract a subdirectory, I need all its contents to be extracted with it. What's the best way of doing this in bash ? Does tar already allow this? 回答1: You can also extract one by one using tar zxvf file.tar.gz PATH/to/file

Mounting and untar'ing a file in Java

一曲冷凌霜 提交于 2019-12-13 17:56:51
问题 I'm currently working on a web application that involves mounting a drive and extracting a tar.gz file, all in Java. Since the application runs in a linux environment, I figured I'd try using unix commands like "mount" and "tar". Runtime runtime = Runtime.getRuntime(); Process proc; String mountCommand = "mount -t cifs -o username=..."; String extractCommand = "tar xzf ..." proc = runtime.exec(mountCommand); proc.waitFor(); proc = runtime.exec(extractCommand); proc.waitFor(); Running the

Linux

ぐ巨炮叔叔 提交于 2019-12-13 11:45:43
一、 通用命令 1、date :打印或者设置系统的日期和时间 2、 stty -a:可以查看或者打印控制字符(Ctrl-C、Ctrl-D、 Ctrl-Z等) 3、 passwd:用passwd -h查看 4、logout,login: 登录shell的登录和注销命令 5、 more, less, head tail: 显示或部分显示文件内容 6、 lp/lpstat/cancel, lpr/lpq/lprm: 打印文件 7、 chmod u+x:更改文件权限 8、 rm -fr dir:删除非空目录 9、cp -R dir:拷贝目录 10、 fg jobid :可以将一个后台进程放到前台 11、 kill 的作用: send a signal to a process、 eg: kill -9 发送的是SIG_KILL信号,具体发送什么信号 可以通过 man kill 查看、 12、 ps 的用法, ps -e 或 ps -o pid,ppid,session,tpgid, comm (其中session显示的sessionid, tpgid显示前台进程组id, comm显示命令名称) 二 、ubuntu常用命令: 1、 dpkg: package manager for Debian   * 安装: dpkg -i package   * 卸载: dpkg -r package

How to pipe tar.extractall from python

风流意气都作罢 提交于 2019-12-13 07:13:56
问题 I'm extracting a tarball using the tarfile module of python. I don't want the extracted files to be written on the disk, but rather get piped directly to another program, specifically bgzip. I'm also trying to use StringIO for that matter, but I get stuck even on that stage - the tarball gets extracted on the disk. #!/usr/bin/env python import tarfile, StringIO tar = tarfile.open("6genomes.tgz", "r:gz") def enafun(members): for tarkati in tar: if tarkati.isreg(): yield tarkati reles =

tar: how to bundle the “extract to directory XXX” info inside a tar file

笑着哭i 提交于 2019-12-13 05:30:41
问题 I know 'tar xf -C DIR' will untar the files in DIR, but is there an option to bundle the "-C DIR" information within the tarball when I create the tar file, so that when I use 'tar xf' the files will be automatically extracted into DIR? Thanks. 回答1: Create DIR, then symlink the files into DIR (no copying involved), then use GNU tar with the dereference (-h) option: mkdir DIR ln -s /path/to/f1 /path2/f2 DIR/ tar chf archive.tar DIR rm -rf DIR This will archive the actual files pointed by the

how to exclude snapshots while running tar in Solaris

╄→гoц情女王★ 提交于 2019-12-13 02:50:41
问题 I'm trying to take a tar of the '/home/store/' directory content. tar cvf store.tar /home/store/ While doing so, I can see that the .snapshot directories are also getting included. My understanding is that snapshots are kind of backups. Can I skip this? If possible, how? Tried excluding a test directory using the below command ran from /home/store/ tar cvfX store.tar <(echo /home/store/test) /home/store/ But this is not excluding the test directory from the tar created. Also, tried this tar

Linux_高级用法

你。 提交于 2019-12-13 00:47:19
LInux如何压缩和解压文件 文件压缩与解压主要讲zip和tar 安静模式和文件夹 zip -r -q -o test.zip 需要打包文件 查看打包文件 du -h test.zip 上节学过的file查看文件类型 file test.zip 加密文件 只需要 zip -r -q -e -o test.zip 需要打包文件 解压文件到文件夹 unzip -q test.zip -d /home/test 不想解压只想查看 unzip -l test.zip 用tar创建一个压缩文件 tar -cf test.tar 需要打包的文件 解压到文件夹 tar -xf test.tar -C /home/test 创建其他文件压缩包, 如*.tar.gz tar -czf test.tar.gz 需要打包的文件 解压文件 tar -xzf test.tar.gz 来源: https://www.cnblogs.com/jly1/p/12032625.html

PHP shell tar problem, return code 2

て烟熏妆下的殇ゞ 提交于 2019-12-13 00:35:37
问题 Want to archive a folder using tar from PHP: $result = shell_exec("tar cf $sourceFile $sourceFolder -C $source > /dev/null; echo $?"); var_dump($result); Output: string(2) "2 " the > /dev/null; echo $? thing is for outputing the result code of a script under linux; the -C $source - changes to the right folder before doing anything This is really strange because when i run this from linux console, it works just fine - creates the archive, so it's not a permission issue. Other sripts like