Tag Info

New answers tagged

1

In man xz, you'll find that -9 requires 674 MiB of memory for compression (and that it's only useful if you're compressing files bigger than 32 MiB). Try adding about this much swap to provide enough virtual memory for the operation (assuming you're using all your current memory for other purposes).


1

If your version of tar uses xz for --lzma (which is likely, even Debian 6 used that), you can use the XZ_OPT variable: XZ_OPT=-9 tar --lzma ...


8

This is because files use up space in whole-block increments. So if your block size is 512 bytes and you have a small 100 byte file, the size it actually uses up will be rounded up to the nearest block - in this case 512. When tarring, because the result is a single file, that inefficiency is reduced since there is only one resultant file - the .tar file. ...


5

The z option tells tar to decompress an archive using gunzip (or its internal equivalent), and is appropriate only for gzip-compressed archives, typically with a .tar.gz extension. To decompress archives using other compression formats, you can try tar xvf file to see if your tar is clever enough to figure things out on its own. If it isn't, you can ...


1

You can search the filesystem for one of those paths, for example (it can take a while): find / -path "*/jdk1.7.0_79/jre/Welcome.html" The output could be: /path/to/unpacked/tarball/jdk1.7.0_79/jre/Welcome.html The place would then be /path/to/unpacked/tarball/


3

They went to whatever was your current directory when you ran tar; if you haven't closed the terminal or changed directories since, pwd will tell you where they are.


1

Yes, thanks to FUSE, which allows filesystems to be implemented by userland programs. There are many FUSE filesystems out there, implementing files stored as something other than sectors on a disk, including alternate views of existing filesystems, files on a remote machine, files in an archive, etc. You can use archivemount to mount a specific archive to a ...


0

$ tar -tzf x.tgz |grep -v '/$' | xargs -n1 -d '\n' echo rm Remove the echo if it looks good. Explanation: tar -tzf x.tgz -- list the contents grep -v '/$' -- skip directories xargs -n1 -d '\n' echo rm -- for each one (-n1) line (-d '\n') of input, run echo rm


0

May be something like this will help you rm -rf `find . -name '*.tgz' -exec tar -tzf '{}' \;` not sure how it will work with so many files.


2

You would need to be at the directory from which the tar file was created, for instance $HOME. Then if you had a tgz of your Documents directory located safely in /backup/Documents.tgz you would do this: $ for file in $(tar -tzf /backup/Documents.tgz); do \ [[ -f $file ]] && rm $file || echo "$file does not exist"; done If you want to also ...


3

As Christopher suggested, archivemount can achieve this. Permits writing of files and when unmounted, the .tar.gz file is automatically updated to reflect the changes. # ls -lh download.tar.gz -rw-rw-r--. 1 steve steve 3.1M Feb 16 2010 download.tar.gz # archivemount download.tar.gz /mnt # cd /mnt # find . -ls|head 1 3127 drwxr-xr-x 0 root root ...


1

The following bash one-liner will do approximately what you describe, putting each directory into its own tarball. for d in dir/*/; do { tar -cj "$d" > "${d%/}.tar.bz2" ; } & done ; while [ "$(jobs)" ] ; do fg &>/dev/null ; done ; echo done


1

tar -cj --newer-mtime 2015-07-07 directory | tar -tj | less works If -N is used, tar works on files whose data modification or status change times are newer than the date given. While --newer-mtime only checks mtime and disregards ctime


10

use the --directory option from man tar : -C,- -directory DIR change to directory DIR i.e.: tar -C /mnt/sdb1/ -czf /mnt/sdb1/old_files/new.tar.gz myfile.csv


1

Use the -C option to tar: -C Directory Causes the tar command to perform a chdir subroutine to the directory specified by the Directory variable.


3

You have first to cd /mnt/sdb1, then launch the tar command. FYI, you don't need to use tarhere as its purpose is to agglomerate several files in a tarball. Since you have only one file here, just use gzip.


2

With GNU or FreeBSD tar, you can apply a transformation to file names when adding them to an archive (or extracting them). tar czf foo.tgz --transform='!^bar/!!' bar/ foo Portably, you can do the same thing with pax. pax -w -pe -s'!^bar/!!' foo bar/


-1

tar cvf archive.tar bar -C /path/to/foo/ .


0

I had a similar problem and found a similar solution, except that I don't have a choice for using PTP over MTP on my device. What I did is : I installed gphotofs and ran gphotofs ~/some-mount-point then I could using rsync as before !


1

You can use the find command to select files based on their modification time. cd /path/to/directory find -type f -newermt 2007-01-01 ! -newermt 2008-01-01 Note that this selects files created in 2007 in your time zone, and files timestamped exactly at midnight on year change are grouped with the preceding year. If your version of CentOS has an old ...


3

tar doesn't take the name of the tar file as an argument. The name of the tar file can be passed as an argument to the -f option. You can write tar -x -f P.tgz or (tar has some weird option parsing for historical reasons) tar xf P.tgz or (if tar doesn't see the name of the tar file, you need to tell it explicitly that it's compressed) tar xz <P.tgz ...


0

I corrected it by using, tar xf P.tgz #added f to the options All archive file name arguments must be following, f option, it looks like...


2

I cobbled together some python to do what you want. It uses python's tarfile library to append stdin to a tar file, and then simply seeks back in the tar to rewrite the header with the right size at eof. The usage would be: rm -f mytar for db in $dbs do mysqldump ... $db | gzip -c | tarappend -t mytar -f mysql-backup-$db.gz done tar tvf mytar Here's ...


1

No, and I miss that feature so much: my question on Ask Ubuntu. If the file to be archived is a raw file with no filesystem metadata associated to it, tar doesn't have neither a filename nor a path necessary to build the internal directories / files tree (to say the least). I think that something can be done in Perl, which has some library dedicated to ...


0

You could consider using the tardy tar post-processor. However, you might question the use of tar and consider some other ways to archive your things. In particular consider rsync and afio Notice that mysqldump understands the --export-all option (see this). You might pipe that into some script understanding the boundaries, etc...


4

Not easily. tar records not only file contents, but also file metadata (name, timestamps, permissions, owner and such). That information has to come from somewhere, and it won't be there in a pipe. You could gzip your database dumps to a file (probably named for the database in question), append the file to a tar archive and then delete the file before ...


0

Here’s a small snippet that converts a ZIP archive to a matching TAR.GZ archive OnTheFly. Convert ZIP archive to TAR archive on the fly # File: zip2tar.py # # Convert ZIP archive to TAR.GZ archive. # # Written by Fredrik Lundh, March 2005. # helpers (tweak as necessary) def getuser(): # return user name and user id return "anonymous", 1000 def ...



Top 50 recent answers are included