tar

How to determine a tar archive's format

倖福魔咒の 提交于 2019-12-12 09:59:37
问题 In Linux, how can I determine the format which was used to create a given tarball? I'd like to detect whether a given archive was created using posix or gnu format. I've already read the man page for GNU tar, which explains how to control the format during creation. However, I don't see anything about how to view the format of an existing file. 回答1: You can use file under Linux to look at the fingerprint of the uncompressed archive (file won't peer beyond the compression layer, so decompress

Compress on the fly a directory in tar.gz format using PHP

笑着哭i 提交于 2019-12-12 09:39:03
问题 I want to compress (on the fly) a directory in tar.gz format using PHP. I know it can be done with exec or using this code (using ZIP format) but my host doesn't support exec and hasn't installed the zip extension of PHP. After searching the internet I came across this PHP code: <?php // Computes the unsigned Checksum of a file’s header // to try to ensure valid file // PRIVATE ACCESS FUNCTION function __computeUnsignedChecksum($bytestring) { for($i=0; $i<512; $i++) $unsigned_chksum += ord(

Tar and save results directly to an SSH directory

那年仲夏 提交于 2019-12-12 06:15:40
问题 I have a server that I would like to make a tar backup of, but the server itself doesn't have enough disk space that is equal to the data it contains. Therefore, I would like to tar it directly to an ssh directory, such that it would dump the tar data into the ssh target without taking huge temporary disk space from the source server. The server is supposed to do an ssh connection and use a directory of the form: ssh user@server.com:/home/user/backupfolder/ Is this possible with simple Linux

Extract tar in memory and nonblocking

痞子三分冷 提交于 2019-12-12 02:05:07
问题 I need to extract a tar.gz datastream in memory. An additional limit is that I cannot block. Deflating in memory works great via zlib . Now I need the untar part. Sadly all libraries I found either block or just work with tar files. Is there any library that works similarly to zlib ? 回答1: You can try libtar. And here is an extraneous sentence to meet the required length of an SO answer. 回答2: Ok, there was no suitable library before. But now there will be, soon. Check it out here but be aware,

Linux 压缩&解压缩

久未见 提交于 2019-12-11 19:56:22
tar命令   解压:tar zxvf FileName.tar   压缩:tar czvf FileName.tar DirName gz命令   解压1:gunzip FileName.gz   解压2:gzip -d FileName.gz   压缩:gzip FileName   .tar.gz 和 .tgz   解压:tar zxvf FileName.tar.gz   压缩:tar zcvf FileName.tar.gz DirName 压缩多个文件:tar zcvf FileName.tar.gz Name1 Name2 Name3 zip命令   解压:unzip FileName.zip   压缩:zip -r FileName.zip DirName 来源: https://www.cnblogs.com/limou956259/p/12024080.html

How to know the files inside the Tar parser

拟墨画扇 提交于 2019-12-11 19:35:28
问题 I am developing a visual c++ application . i need to know the file type (i mean whether it contains .png file or.html file or .txt file) present inside the tar file(just by c++ prgramming)-Nothing to deal with the commands. I have got some knowledge on the link below- how to parse a tar file here i have got information that at buffer[512] we have contents of a file present inside thge tar file.My first quesion is (1.) suppose if i have more then 1 files present in tar and i got the size from

Add last n lines of files to tar/zip

こ雲淡風輕ζ 提交于 2019-12-11 16:57:39
问题 I need to regularly send a collection of log files that can grow quite large, so I would like to only send the last n lines of the each of the files. for example: /usr/local/data_store1/file.txt (500 lines) /usr/local/data_store2/file.txt (800 lines) Given a file with a list of needed files named files.txt , I would like to create an archive (tar or zip) with the last 100 lines of each of those files. I can do this by creating a separate directory structure with the tail-ed files, but that

Linux常用基本命令大全

情到浓时终转凉″ 提交于 2019-12-11 16:13:53
Linux常用基本命令大全 原创 flying_man_ 发布于2018-11-14 09:27:29 阅读数 18651 收藏 更新于2019-07-29 10:57:21 分类专栏: Linux 版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。 本文链接: https://blog.csdn.net/flying_man_/article/details/84060683 展开 ls ls -a 显示指定目录下所有目录与文件,包括隐藏文件 -l 以列表的方式显示文件的详细信息 -h 配合-l以人性化的方式显示文件大小 隐藏文件和隐藏文件夹是用来配置应用的。 通配符的使用 * ----- 代表任意个数个字符 ? ----- 代表任意一个字符,至少一个 [] ------ 表示可以匹配字符族中的任意一个 [abc] ---- 匹配 a 、 b 、 c 中的任意一个 [a-f] ------ 匹配从 a 到 f 范围内的任意一个字符 cd change directory 的缩写,其功能为更改当前的工作目录,也是用户最常用的命令之一。 cd 回到家目录(/home/用户目录) cd ~ 回到家目录(/home/用户目录) cd . cd .. cd - 可以在最近两次目录之间来回切换 touch 创建文件或修改文件时间

How does ansible's unarchive module look for the tar binary?

為{幸葍}努か 提交于 2019-12-11 15:49:24
问题 I'm trying to execute an ansible playbook that has a task utilizing the unarchive module. Because I'm doing this on OSX, I need it to use gnu-tar , instead of the bsd tar that typically comes with OSX, since BSD tar is not officially supported. I've installed gnu-tar using brew , and placed this package's gnubin folder ahead of other paths in the $PATH variable. However, my playbook still looks for tar in the /usr/bin folder (the location of the original tar ), instead of the newly installed

Extract File With LibTar

我是研究僧i 提交于 2019-12-11 14:57:48
问题 I have a little problem when I'm trying to extract a file using Libtar. This is my code: int htlp_decompress_decompress(char * filename) { TAR * tar_file; char rootdir[200]; strcpy(rootdir, "/var/cache/htpackage/"); if (tar_open(&tar_file, filename, NULL, O_RDONLY, 0, TAR_GNU) == -1) { fprintf(stderr, "tar_open(): %s\n", strerror(errno)); return -1; } if (tar_extract_all(tar_file, rootdir) != 0) { fprintf(stderr, "tar_extract_all(): %s\n", strerror(errno)); return -1; } if (tar_close(tar_file