Tag Info

Hot answers tagged

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.


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:" ...


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: ...


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 ...


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 ...


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 ./


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 ...


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 ...


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 ...


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 - > ...


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, ...


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 ...


2

tar's default mode is to preserve ownership and permissions on archive creation; I don't believe there's even an option not to store the data. When you extract an archive, if you're a normal user, the default is to use stored permissions minus the umask and set the owner to whoever's extracting; if you're superuser, the default is to use stored permissions ...


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.


2

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

try (in one line, I fold for readability) tar -zcvf api_v2.x.tar.gz --exclude api/distributor_test.php --exclude api/library/Distributor_API.php api argument (e.g. api) should be put last you may use --exclude distributor_test.php (if you only have one file named distributor_test.php )


1

tar always stores the modification time of the files it puts into the archive. If you like to get the current time of extraction while extracting the archive, the only way to achieve this is to use tar xm < xxx.tar at extraction time.


1

Whether a file can be assigned a different user id (e.g. while extracting a tararchive) does not depend on whether you are superuser but on whether you have the permission to do so. There are several possible reasons why you may have this permission: 1) you are on HP-UX where this is generally permitted. This is seen to be a security risk. 2) you have the ...


1

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


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!


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 -


1

You are not using tar but gtar and the error message: tar: Archive contains obsolescent base-64 headers is related to a well known bug in gtar that is reported repeatedly since more than 20 years. There have been source changes in the past that made this problem less probable but these changes did not yet really fix the related problem in gtar. If you ...


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 ...



Only top voted, non community-wiki answers of a minimum length are eligible