Tag Info

New answers tagged

2

The tar-file should be located in the very directory from which you ran the command. To find out where you are, type pwd -P. See this article for an explanation why to use the -P.


1

The file is created in place where you executed the script. You can see your current location using pwd. However, you can also pass path instead of archive-name: tar -zcvf /my/absolute/path/archive-name.tar.gz directory-name File will be located in /my/absolute/path. You can also use relative path, if the directory is there: tar -zcvf ...


1

My tar implementation is the best method star -cv -f out.tar -find protTests ! -type l


3

You could do this, to supply tar with a list of all files inside protTests except those which are symlinks: find protTests -maxdepth 1 -mindepth 1 -not -type l -print0 | tar --null --files-from - -cvf protTests.tar By the way, your existing command: tar -cvf protTests.tar protTests/* will not archive all files in protTests, it will only archive ...


0

I think this command will do the trick ssh user@host "cd /path/to/data/;tar zcf directory_name" | tar zxf Now, first of all you have to execute this command from the target host. And details to be explained: ssh user@host will open connection to host machine, from where the data is to be transfered. cd /path/to/data will take to the directory where ...


1

There is no way to put new meta data into a tar archive, but there is a way to extract just the meta data from a tar archive to the filesystem. Just call: star -xp -meta < archive.tar This will not create new files or overwrite file content but just restore the meta data from the archive to the files in the local filesystem. You most likely need -U in ...


7

You'd need to replace that ~ with your home directory first. Assuming your home directory doesn't contain : (they generally don't as otherwise they couldn't be referenced in /etc/passwd): (cd / && sed "s:^~:$HOME:" | pax -w | gzip) < file.list > file.tar.gz Or if your tar is the one from GNU or bsdtar: (cd / && sed "s:^~:$HOME:" ...


10

Use the -T option: -T, --files-from FILE get names to extract or create from FILE Note that it doesn't work with ~ as alias for home directory, you need to specify the folder explicitly.


2

You could use something like this to archive and copy through ssh: tar zcvf - stuff/ | ssh alex@localhost 'cat - > /tmp/stuff.tar.gz' Here you are creating a tar.gz archive but instead of saving it to some file you are using - which is standard output. The standard output - is then piped to ssh and from there on you cat from standard output cat - > ...


3

piping should be enough. Doing just: tar -cvj /path/to/your/files | ssh remote "cat > file.tar.bz2" (if you have set up passwordless log in using keys) Later on the other machine you can decompress the received file using tar -xvf path.tar.bz2 -C ./


0

The incremental features in gtar have a conceptional problem and cannot work correctly in all cases. When I tried to check the incremental features on star in 2004, gtar failed early and could not be tested at all. Did you try star's incremental bsckups? Freebsd uses star for zfs backups and this works fine since freebsd fixed some old kernelbugs.


0

I recommend to use star as star comes with a builtin find. This enables features that cannot be achieved with a separate find command.


0

star -c -C startdir -find . ! -type d > out.tar Ommit -C startdir and replace . by startdir if it should appear in the archive. This is the most efficient method based on the features of libfind. Libfind also offers primaries -chown -chgrp -chmod that modify struct stat in place and allow to archive different metadata. This also works in list and extract ...


0

I might have found a solution. find mydir -type f -printf '%P\0'|tar czvf mydir.tar.gz -C mydir --null -T - This might be costly a little, but anyway it will work, because this doesn't depend on xargs.


2

You don't have to chroot to tar things. You can use the --numeric-owner option instead. Chroot is only necessary if you also want to record the (correct) owner/group names inside the tar archive, which is not strictly necessary in this case [when /etc/passwd etc. is part of the tar]. And without actually chrooting you also don't need to mount /dev, /proc, ...


1

FreeBSD's tar doesn't support the xar format, but once again ports to the rescue - archivers/xar seems to be what you want!


2

It's a joke. tar (Tape ARchive) is the name of the program used to create an archive that contains several files, all glued together. Tar is also a black and sticky substance obtained from hydrocarbons. It translates to catrame in Italian (from your name, I suppose you're Italian). Therefore, if you take a bunch of files and stick and roll all of them ...


0

It's better not to change the officialy installed package libpng12-dev but rather to indicate in the Makefile from libbpg where to find libpng 1.6 So I modify the Anthon's solution : # install dev packages needed sudo apt-get install -y libsdl-image1.2-dev libsdl1.2-dev libjpeg8-dev # download, configure, make and make install PNG 1.6 (You coul find a ...


0

An alternative privilege-less approach is to use the fakeroot program to pretend that you are allowed to change ownership. While other tar attributes are lost, it does keep the mode, mtime and uid/gid. These commands create a temporary directory, extract a subset of the files and finally creates a new archive: mkdir tmp <some.tar.gz \ fakeroot -- sh -c ...


7

bsdtar (based on libarchive) can filter tar (and some other archives) from stdin to stdout. It can for example pass through only filenames matching a pattern, and can do s/old/new/ renaming. It's already packaged for most distros, for example as bsdtar in Ubuntu. sudo apt-get install bsdtar # or aptitude, if you have it. # example from the man page: ...


0

tar --use-compress-program=pigz .... replace pigz with your favorite parallel compression program. The reason to use tar is because it can store the owner, group, permissions. That metadata is often useful (e.g., restoring a dir tree in a complex system).


3

The easiest way would be to copy the whole archive; I presume you don't want to do that because it's too large. The usual command line tools (tar, pax) don't support copying members of an archive to another archive. If you didn't need to preserve ownership, I'd suggest using FUSE filesystems. You can use archivemount to mount an archive as a filesystem; do ...


-1

From what I know, the tar command cannot use the tar format both as input and output. You will have to extract your files locally somehow, and use tar again to create a tarfile on-the-fly, with something like this (the - means standart input/output is used instead of a file) : tar cf - subdir/ | ssh remote@system 'cd extractdir && tar xvf -' ...


0

OP asked this over in Stackoverflow too. Here's the answer I offered there. The selection and order of files in this answer is determined by the order out of find, so "first" isn't well-defined here. This may also depend on GNU Awk 4.1.0. find . -type f | awk -v N=10 -F / 'match($0, /.*\//, m) && a[m[0]]++ < N' | xargs -r -d '\n' tar -rvf ...


0

I am using a mac, and found that excludes weren't working unless the top level folder is the last argument example of working command: tar czvf tar.tgz --exclude='Music' dir FYI: $: tar --version bsdtar 2.8.3 - libarchive 2.8.3


4

If your pax supports the -0 option, with zsh: print -rN dir/**/*(D/e:'reply=($REPLY/*(ND^/[1,10]))':) | pax -w0 | xz > file.tar.xz It includes the first 10 non-directory files of each directory in the list sorted by file name. You can choose a different sorting order by adding the om glob qualifier (order by modification time, Om to reverse the ...


4

Well @stevepusser from forums.debian.net helped me :) The trick is to create a package from the ppa. The official tutorial with much more details can be found here: debian/wiki/CreatePackageFromPPA But to install powernap you should follow these steps: - Install the Debian SDK: apt-get install devscripts build-essential - Add the PPA source url to your ...


0

The easiest (or most easy to understand) way is to use xargs with the -N max-args option. Keep in mind, that your input always needs to be something, which does not require a commandline, so echo *.* will work as input, where ls *.* does not (too long ls commandline) find should be fine, as its argument is only the path, not a list of files.


1

for d in ./*/ do cd "$d" tar -rvf ../backup.tar $(ls | tail -10) cd .. done gzip backup.tar other variant find * -prune -type d -exec bash -c 'printf "%s\n" $0/* | tail -10' {} \; | tar czvf backup.tar.gz -T -


2

Suppose your master directory is /tmp/dir from which you want to archive only N (e.g N=10) files of each (sub) folder under it to a backup.tar.gz file. Example tree for /tmp/dir: dir/ ...


2

Since the output of find is flat, you don't really know which files belong to the same directories without looking at the paths. The alternative is to use multiple finds (one per folder), without having to look at the paths. This is what I did. In order to tar up to a maximum of 10 files of each subfolder, use something like this: for dir in $(find . -type ...


0

Use a hash on the directory name, and only emit the filename if the hash value count is below the threshold. E.g. find . -depth -type f \ | perl -MFile::Spec -nle '(undef,$d,$f)=File::Spec->splitpath($_); print if $seen{$d}++ < 3' \ | tar ...


0

Check two items: (1) Is the FILE INCOMPLETE due to a faulty download? Re-download, and use the -c option if your are using wget. (happens all the time). (2) Does the .tar or .tar.gz filename have ILLEGAL CHARACTERS. It's best to keep archive names simple, short, composed of letters and numbers. (happens all the time). So just rename the file. This one ...


0

The original UNIX tar command did not compress archives. As was mentioned in a comment, Solaris tar doesn't compress. Nor does HP-UX, nor AIX, FWIW. By convention, uncompressed archives end in .tar. With GNU/Linux you get GNU tar. (You can install GNU tar on other UNIX systems.) By default it does not compress; however, it does compress the resulting ...


3

Drop the space after -, or even drop - entirely: tar xvf grads-2.0.2.oga.2-bundle.tar.gz



Top 50 recent answers are included