tar

How do I exclude absolute paths for tar?

我是研究僧i 提交于 2019-12-20 10:32:05
问题 I am running a PHP script that gets me the absolute paths of files I want to tar up. This is the syntax I have: tar -cf tarname.tar -C /www/path/path/file1.txt /www/path/path2/path3/file2.xls When I untar it, it creates the absolute path to the files. How do I get just /path with everything under it to show? 回答1: If you want to remove the first n leading components of the file name, you need strip-components . So in your case, on extraction, do tar xvf tarname.tar --strip-components=2 The man

How can I untar a tar.bz file in unix?

冷暖自知 提交于 2019-12-20 10:20:04
问题 I've found tons of pages saying how to untar tar.bz2 files, but how would one untar a tar.bz file? 回答1: use the -j option of tar . tar -xjf /path/to/archive.tar.bz 回答2: According to the man pages for bzip2 If the file does not end in one of the recognised endings, .bz2, .bz, .tbz2 or .tbz, bzip2 complains that it cannot guess the name of the original file, and uses the original name with .out appended. Based on this, I'm guessing that '.bz' is considered a valid suffix for bzip2 compressed

Programmatically extract tar.gz in a single step (on Windows with 7-Zip)

霸气de小男生 提交于 2019-12-20 09:27:48
问题 Problem: I would like to be able to extract tar.gz files in a single step. This makes my question almost identical to this one: Stack Overflow question for tar-gz. My question is almost the same, but not the same, because I would like to do this on windows using 7-Zip command-line (or something similar) inside a bat file or Ruby/Perl/Python script. Question: This seemingly simple task is proving to be more involved than the first appearance would make it out to be. Does anyone have a script

How do I extract files without folder structure using tar

为君一笑 提交于 2019-12-20 08:47:00
问题 I have a tar.gz-file with the following structure: folder1/img.gif folder2/img2.gif folder3/img3.gif I want to extract the image files without the folder hierarchy so the extracted result looks like: /img.gif /img2.gif /img3.gif I need to do this with a combination of Unix and PHP. Here is what I have so far, it works to extract them to the specified directory but keeps the folder hierarchy: exec('gtar --keep-newer-files -xzf images.tgz -C /home/user/public_html/images/',$ret); 回答1: You can

More efficient way to find & tar millions of files

别等时光非礼了梦想. 提交于 2019-12-20 08:37:26
问题 I've got a job running on my server at the command line prompt for a two days now: find data/ -name filepattern-*2009* -exec tar uf 2009.tar {} ; It is taking forever , and then some. Yes, there are millions of files in the target directory. (Each file is a measly 8 bytes in a well hashed directory structure.) But just running... find data/ -name filepattern-*2009* -print > filesOfInterest.txt ...takes only two hours or so. At the rate my job is running, it won't be finished for a couple of

How do I append files to a .tar archive in Java?

*爱你&永不变心* 提交于 2019-12-20 04:37:17
问题 I would like to create a tar archive in Java. I have files which are constantly being created and I'd like a worker thread to take a reference to those files from a queue and copy them into the archive. I tried using Apache Compression library's TarArchiveOutputStream to do this, but I do not wish to keep the archive open for the entire duration of the program (since unless i finalize the archive, it can become corrupted - so i'd rather append to it in batches), and I haven't found a good way

源码安装Ansible

牧云@^-^@ 提交于 2019-12-20 02:54:20
一、Ansible介绍 ansible是一款的自动化运维工具,基于Python开发,集合了众多运维工具(puppet、cfengine、chef、func、fabric)的优点,实现了批量系统配置、批量程序部署、批量运行命令等功能。ansible是基于模块工作的,本身没有批量部署的能力。真正具有批量部署的是ansible所运行的模块,ansible只是提供一种框架。主要包括: 1、连接插件connection plugins:负责和被监控端实现通信; 2、host inventory:指定操作的主机,是一个配置文件里面定义监控的主机; 3、各种模块核心模块、command模块、自定义模块; 4、借助于插件完成记录日志邮件等功能; 5、playbook:剧本执行多个任务时,非必需可以让节点一次性运行多个任务。 二、Ansible特性 1、no agents:不需要在被管控主机上安装任何客户端; 2、no server:无服务器端,使用时直接运行命令即可; 3、modules in any languages:基于模块工作,可使用任意语言开发模块; 4、yaml,not code:使用yaml语言定制剧本playbook; 5、ssh by default:基于SSH工作; 6、strong multi-tier solution:可实现多级指挥。 三、Ansible优点 1、轻量级

一文搞定Ubuntu常用压缩与解压命令

谁说我不能喝 提交于 2019-12-19 21:46:26
1.zip #压缩 zip archive_name . zip file_name #文件 zip - r archive_name . zip directory_to_compress #目录 #解压 unzip archive_name . zip 2.tar / .tar.gz&.tgz / .tar.bz2 / .gz .tar #打包 tar - cvf archive_name . tar directory_to_compress #解包 tar - xvf archive_name . tar tar - xvf archive_name . tar - C / tmp / extract_here / .tar.gz /.tgz #压缩 tar - zcvf archive_name . tar . gz directory_to_compress #解压 tar - zxvf archive_name . tar . gz tar - zxvf archive_name . tar . gz - C / tmp / extract_here / .tar.bz2 #压缩 tar - jcvf archive_name . tar . bz2 directory_to_compress #解压 tar - jxvf archive_name . tar .

linux中tar命令用法

故事扮演 提交于 2019-12-19 08:51:30
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包中所有文件,-x是解开的意思 压缩 tar –cvf jpg.tar *.jpg 将目录里所有jpg文件打包成tar.jpg tar –czf

CENTOS基本信息和SSH

核能气质少年 提交于 2019-12-19 06:25:23
centos含义:centos是linux系统的一个发行版。也就是linux系统中的一个。它是基于linux红帽版本制作的。红帽版因为是商业版,所以很多东西是要钱的。但是centos完全免费,主要用作服务器的搭建。 特点:在CentOS的全称里面,我们可以看到Enterprise OS,也就是说企业系统,这个企业系统并不是企业级别的系统,而是它可以提供企业级应用所需要的要素。例如:稳定的环境,长期的升级更新支持,保守性强,大规模的系统也能够发挥很好的性能 最新版本特点: 1.可以把CentOS理解为Red Hat AS系列!它完全就是对Red Hat AS进行改进后发布的!各种操作、使用和RED HAT没有区别! 2.CentOS完全免费,不存在RED HAT AS4需要序列号的问题。 3.CentOS独有的yum命令支持在线升级,可以即时更新系统,不像RED HAT那样需要花钱购买支持服务! 4.CentOS修正了许多RHEL的BUG! 5.CentOS版本说明:CentOS3.1 等同于 RED HAT AS3 Update1 CentOS3.4 等同于 RED HAT AS3 Update4 CentOS4.0 等同于 RED HAT AS4 centos基本命令: 1.关机 (系统的关机、重启以及登出 ) 的命令 shutdown -h now 关闭系统(1) init 0