tar

Deleting files after adding to tar archive

牧云@^-^@ 提交于 2019-12-02 19:59:22
Can GNU tar add many files to an archive, deleting each one as it is added? This is useful when there is not enough disk space to hold both the entire tar archive and the original files - and therefore it is not possible to simply manually delete the files after creating an archive in the usual way. Fred Foo With GNU tar, use the option --remove-files . Cristopher Plasma I had a task - archive files and then remove into OS installed "tar" without GNU-options. Method: Use "xargs" Suppose, we are have a directory with files. Need move all files, over the week into tar and remove it. I do one

How to compare two tarball's content

偶尔善良 提交于 2019-12-02 18:54:11
I want to tell whether two tarball files contain identical files, in terms of file name and file content, not including meta-data like date, user, group. However, There are some restrictions: first, I have no control of whether the meta-data is included when making the tar file, actually, the tar file always contains meta-data, so directly diff the two tar files doesn't work. Second, since some tar files are so large that I cannot afford to untar them in to a temp directory and diff the contained files one by one. (I know if I can untar file1.tar into file1/, I can compare them by invoking

文件备份与压缩命令

萝らか妹 提交于 2019-12-02 17:15:20
tar z:通过gzip压缩或者解压 c:创建新的tar包 v:显示详细得执行过程 f:指定压缩结果文件的名字 t:不解压查看tar包的内容 p:保持文件的原有属性 x:解开tar包 --exclude=文件路径 打包时,跳过的文件或目录 -X 文件名 从指定文件里面读取不需要处理的文件或目录集合 -h : 打包软连接文件指向的真实文件    即使不指定为gzip 没有z选项,tar 命令会自动判断压缩包的类型,进而选择合适的解压 注意:exclude后面接的路径不能以/结尾 注意:不包括文件和压缩目录的位置 若需要打包的目录为相对路径,则--exclude 后面只能杰相对路径 若需要打包的目录为绝对路径,则--exclude后面可以时绝对路径也能接相对路径 为了方便起见,打包路径和--exclude后面的路径都应该保持一致即可 来源: https://www.cnblogs.com/betterquan/p/11756506.html

linux命令

断了今生、忘了曾经 提交于 2019-12-02 17:13:44
1 .cd命令 cd 回到跟目录 cd uqihong 进入到uqihong这个文件夹(且cd命令只能一级一级的进入) 2.复制命令 cp -r /usr/local/tomcat-ushangxue-www/. /usr/local/tomcat-uqihong-www 将一个文件夹下所有内容复制到另一个文件夹 cp -r /TEST/test1 /TEST/test2 将test1文件夹复制到test2下,test1文件夹会在test2文件夹下 cp /TEST/test1/test01 /TEST/test2 将test01文件复制到test2文件夹下    cp的参数讲解    -a :相当于 -pdr 的意思;   -d :若来源文件为连结文件的属性(link file ),则复制连结文件属性而非档案本身;   -f :为强制 (force) 的意思,若有重复或其它疑问时,不会询问使用者,而强制复制;   -i :若目的檔(destination)已经存在时,在覆盖时会先询问是否真的动作!   -l :进行硬式连结 (hard link) 的连结档建立,而非复制档案本身;   -p :连同档案的属性一起复制过去,而非使用预设属性;   -r :递归持续复制,用于目录的复制行为;   -s :复制成为符号连结文件 (symbolic link),亦即『快捷方式』档案;   

How do I extract files without folder structure using tar

社会主义新天地 提交于 2019-12-02 16:58:11
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); You can use the --strip-components option of tar. --strip-components count (x mode only) Remove the specified number

More efficient way to find & tar millions of files

烈酒焚心 提交于 2019-12-02 16:19:56
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 weeks .. That seems unreasonable. Is there a more efficient to do this? Maybe with a more complicated

tar: add all files and directories in current directory INCLUDING .svn and so on

≯℡__Kan透↙ 提交于 2019-12-02 16:03:59
I try to tar.gz a directory and use tar -czf workspace.tar.gz * The resulting tar includes .svn directories in subdirs but NOT in the current directory (as * gets expanded to only 'visible' files before it is passed to tar I tried to tar -czf workspace.tar.gz . instead but then I am getting an error because '.' has changed while reading: tar: ./workspace.tar.gz: file changed as we read it Is there a trick so that * matches all files (including dot-prefixed) in a directory? (using bash on Linux SLES-11 (2.6.27.19) Don't create the tar file in the directory you are packing up: tar -czf /tmp

[linux系统常用命令大全]

这一生的挚爱 提交于 2019-12-02 15:52:04
[linux系统常用命令大全] #系统信息: arch 显示机器的处理器架构(1) uname -m 显示机器的处理器架构(2) uname -r 显示正在使用的内核版本 dmidecode -q 显示硬件系统部件 - (SMBIOS / DMI) hdparm -i /dev/hda 罗列一个磁盘的架构特性 hdparm -tT /dev/sda 在磁盘上执行测试性读取操作 cat /proc/cpuinfo 显示CPU info的信息 cat /proc/interrupts 显示中断 cat /proc/meminfo 校验内存使用 cat /proc/swaps 显示哪些swap被使用 cat /proc/version 显示内核的版本 cat /proc/net/dev 显示网络适配器及统计 cat /proc/mounts 显示已加载的文件系统 lspci -tv 罗列 PCI 设备 lsusb -tv 显示 USB 设备 date 显示系统日期 cal 2007 显示2007年的日历表 date 041217002007.00 设置日期和时间 - 月日时分年.秒 clock -w 将时间修改保存到 BIOS #关机 (系统的关机、重启以及登出 ) shutdown -h now 关闭系统(1) init 0 关闭系统(2) telinit 0 关闭系统(3)

How to extract filename.tar.gz file

爷,独闯天下 提交于 2019-12-02 15:45:15
I want to extract an archive named filename.tar.gz . Using tar -xzvf filename.tar.gz doesn't extract the file. it is gives this error: gzip: stdin: not in gzip format tar: Child returned status 1 tar: Error exit delayed from previous errors If file filename.tar.gz gives this message: POSIX tar archive, the archive is a tar, not a GZip archive. Unpack a tar without the z , it is for gzipped (compressed), only: mv filename.tar.gz filename.tar # optional tar xvf filename.tar Or try a generic Unpacker like unp ( https://packages.qa.debian.org/u/unp.html ), a script for unpacking a wide variety of

Excluding directory when creating a .tar.gz file

倖福魔咒の 提交于 2019-12-02 15:42:10
I have a /public_html/ folder, in that folder there's a /tmp/ folder that has like 70gb of files I don't really need. Now I am trying to create a .tar.gz of /public_html/ excluding /tmp/ This is the command I ran: tar -pczf MyBackup.tar.gz /home/user/public_html/ --exclude "/home/user/public_html/tmp/" The tar is still being created, and by doing an ls -sh I can see that MyBackup.tar.gz already has about 30gb, and I know for sure that /public_html/ without /tmp/ doesn't have more than 1GB of files. What did I do wrong? Try removing the last / at the end of the directory path to exclude tar