tar

Different name of unpacked tar.gz folder using tarfile.extractall()

流过昼夜 提交于 2019-12-11 12:33:40
问题 I am using pythons tarfile.extractall() to unpack a foo.tar.gz file. I want to access the extracted folder, but sometimes the extracted folder has a different name than the packed file. I need a way to control the name of the extracted folder or, a return value that tells me the name of the extracted folder. Example packed file: foo-rc-2.0.0.tar.gz unpacked folder: foo-2.0.0-rc 回答1: tarfile.extractall() simply extracts all the files in the tarball to the current directory, or a directory of

12月11日

半城伤御伤魂 提交于 2019-12-11 11:52:56
文档的压缩和打包 .gz 表示由gzip压缩工具压缩的文件 .tar 表示由tar打包程序打包的文件 .tar.gz 先由tar打包,再由gzip压缩 gzip压缩工具 -d 该参数在解压缩时使用 -# 表示压缩等级,1为最差,9为最好,6为默认 xz压缩工具 tar打包工具 来源: https://www.cnblogs.com/tui463/p/12021339.html

Python: Extracting specific files with pattern from tar.gz without extracting the complete file

元气小坏坏 提交于 2019-12-11 10:37:21
问题 I want to extract all files with the pattern *_sl_H* from many tar.gz files, without extracting all files from the archives. I found these lines, but it is not possible to work with wildcards (https://pymotw.com/2/tarfile/): import tarfile import os os.mkdir('outdir') t = tarfile.open('example.tar', 'r') t.extractall('outdir', members=[t.getmember('README.txt')]) print os.listdir('outdir') Does someone have an idea? Many thanks in advance. 回答1: First you can use glob to get you a list of the

How do I extract a .tar file in pure PHP on Windows?

十年热恋 提交于 2019-12-11 10:09:49
问题 I have a PHP script that I want to run on Windows. I need to extract a .tar file. How do I extract the tar file. I know of the PharData class and that works on Linux but not on Windows. My script just dies, no error output or anything. This same block of code runs on Linux. I'm using PHP 5.4.0 on Windows $phar_data = new PharData($out_filepath); $phar_data->extractTo($destination_folder); Is there an alternative pure PHP way to extract a .tar file? edit: I should say my real intent is to

压缩和解压缩命令

自闭症网瘾萝莉.ら 提交于 2019-12-11 08:53:02
压缩和解压缩命令 .zip格式 .gz格式(不会打包) .bz2格式(不能压缩目录) .tar格式(打包不会压缩) .tar.gz 和 .tar.bz2格式 .zip格式 “.zip"是Windows中最常见得压缩格式,Linux也可以识别”.zip"格式,这可以方便地和Windows系统通用压缩文件 ".zip"格式得压缩命令 命令名称 zip 英文原意 package and compress(archive) files 所在路径 /usr/bin/zip 执行权限 所有用户 功能描述 压缩文件或目录 命令格式 [root@localhost ~]# zip [选项] 压缩包名 源文件或源目录 选项 功能 -r 压缩目录 例子: [root@localhost ~]#zip ana.zip anacoonda-cfg ".zip"格式得解压缩命令 命令名称 unzip 英文原意 list,test and extract compressed files in a ZIP archive 所在路径 /usr/bin/unzip 执行权限 所有用户 功能描述 测试和提取压缩文件中得文件 命令格式 [root@localhost ~]# unzip [选项] 压缩包名 选项 功能 -d 指定解压缩位置 例子 [root@localhost ~]# unzip -d /tmp/

How to listfiles() from jar in a tar by using truezip in Java?

怎甘沉沦 提交于 2019-12-11 07:33:32
问题 I am trying to list all files in a tar, including files in jar. How can I do this by using truezip in Java or other api? Thanks 回答1: Using TrueZIP 7, you could use something like this: public static void main(String args[]) throws IOException { // Remember to set to add the following dependencies to the class path: // Compile time artifactId(s): truezip-file // Run time artifactId(s): truezip-kernel, truezip-driver-file, truezip-driver-tar, truezip-driver-zip TFile.setDefaultArchiveDetector

Import .tar file using Azure Data Factory

白昼怎懂夜的黑 提交于 2019-12-11 07:26:56
问题 How do I import a TAR file using Azure Data Factory and unzip (decompress) them into Azure Data lake store. I could find it possible for .gZ and .zip files but not .tar! Just FYI, my .tar file sits in the on-premise file system. Request your kind help. 回答1: You can create a .NET custom activity to install the tar.exe command (that you will have uploaded to Blob store) and run it: https://docs.microsoft.com/en-us/azure/data-factory/data-factory-use-custom-activities You can adapt the following

How to convert tar.gz file to zip using Python only?

╄→尐↘猪︶ㄣ 提交于 2019-12-11 05:38:46
问题 Does anybody has any code for converting tar.gz file into zip using only Python code? I have been facing many issues with tar.gz as mentioned in the How can I read tar.gz file using pandas read_csv with gzip compression option? 回答1: You would have to use the tarfile module, with mode 'r|gz' for reading. Then use zipfile for writing. import tarfile, zipfile tarf = tarfile.open( name='mytar.tar.gz', mode='r|gz' ) zipf = zipfile.ZipFile( file='myzip.zip', mode='a', compression=zipfile.ZIP

tar: preserving only file names, contents and executable bit

拥有回忆 提交于 2019-12-11 04:39:01
问题 I want to use tar to preserve only file names, file contents, and the executable bit for the owner (and ignore the executable bit for group and other). The command I have come up with is tar -cf <name>.tar --numeric-owner --owner=0 --group=0 --mode="go-rwx,u-rw" <files> I would like the output <name>.tar not to change unless I change the file name, file contents, or owner's executable bit in one or more of <files> . Assume that the <files> are in sorted order by name. Will the command that I

How to compress a tar file in a tar.gz without directory?

房东的猫 提交于 2019-12-11 03:28:54
问题 I'm looking for a way to compress a tar file in a tar.gz without directory. Today my code generate a TAR file without directory with "tarfile" library and arcname arguments but when I want to compress this TAR file in TAR.GZ I don't understand how to delete directory. I have made many tests in the last 3 days. My code : Tarname = example.tar ImageDirectory = C:\... TarDirectory = C:\.. tar = tarfile.open(Tarname, "w") tar.add(ImageDirectory,arcname=TarName) tar.close() targz = tarfile.open(