The tar archive format and/or the command-line utility for working with tar files.

learn more… | top users | synonyms

20
votes
6answers
28k views

tar --exclude doesn't exclude. Why?

I have this very simple line in a bash script which executes successfully (i.e. producing the _data.tar file), except that it doesn't exclude the sub-directories it is told exclude via the --exclude ...
19
votes
5answers
8k views

How can I best copy large numbers of small files over scp?

I have a directory that's got several gigabytes and several thousand small files. I want to copy it over the network with scp more than once. CPU time on the source and destination machines is cheap, ...
19
votes
5answers
12k views

How to XZ a directory with TAR using maximum compression?

So I need to compress a directory with max compression. How can I do it with xz? I mean I will need tar too because I can't compress a directory with only xz. Is there a oneliner to produce e.g. ...
18
votes
2answers
850 views

What does .??* mean in a shell command?

The following command will tar all "dot" files and folders: tar -zcvf dotfiles.tar.gz .??* I am familiar with regular expressions, but I don't understand how to interpret .??*. I executed ls .??* ...
18
votes
3answers
32k views

Add/update a file to an existing tar.gz archive?

Is there a way to add/update a file in a tar.gz archive? Basically, I have an archive which contains a file at /data/data/com.myapp.backup/./files/settings.txt and I'd like to pull that file from the ...
16
votes
3answers
4k views

How to choose directory name during untarring

Say I have file named ugly_name.tar, which when extracted, becomes ugly_name directory. What command can I use such that the resulting directory name is pretty_name instead?
16
votes
2answers
9k views

tar cvf or tar -cvf ?

I have learned to use tar without '-' for options, like tar cvfz dir.tar.gz Directory/ but I recently came accross the slightly different tar -czvf syntax (I think the 'f' must be the last option in ...
14
votes
5answers
6k views

Is there a parallel file archiver (like tar)?

Is there something out there for parallel archiving of files? Tar is great, but I don't use tape archives, and it's more important to me that the archiving happens quickly (with compression like ...
14
votes
4answers
555 views

How can I determine if running tar will cause disk to fill up

If I run tar -cvf on a directory of size 937MB to create an easily downloadable copy of a deeply nested folder structure, do I risk filling the disk given the following df -h output: /dev/xvda1 ...
13
votes
7answers
6k views

What to use to backup files, preserving ACLs?

When using the tar utility to store files in backups one loses the extended ACLs. Is there some commonly used and not hackish solution (like: create a script that will recrate the ACLs from scratch) ...
12
votes
3answers
2k views

Why use superflous dash (-) to pass option flags to tar?

To create a tar file for a directory, the tar command with compress, verbose and file options can be typed thus: $ tar -cvf my.tar my_directory/ But it also works to do it this way: $ tar cvf ...
12
votes
1answer
14k views

How do you extract a single folder from a large tar.gz archive?

I am using this command on a 5GB archive tar -zxvf archive.tar.gz /folder/in/archive is this the correct way to do this? It seems to be taking forever with no command line output...
11
votes
3answers
586 views

What are the differences between bsdtar and GNU tar?

I've always used GNU tar. However, all GNU/Linux distributions that I've seen ship bsdtar in their repositories. I've even seen it installed by default in some, IIRC. I know for sure that Arch ...
11
votes
2answers
703 views

Tar up all PDFs in a directory, retaining directory structure

I'm trying to create a compressed tarball that contains all PDF files that exist in one of my directories. The directory structure needs to be retained. Empty directories are not needed, but I really ...
11
votes
5answers
1k views

How to de-unzip, de-tar -xvf — de-unarchive in a messy folder?

Usually, I unarchive things by $ mkdir newFolder; $ mv *.zip newFolder; $ cd newFolder; $unzip *.zip but sometimes I get lazy and just do in an arbitrary folder $ unzip *.zip so time-to-time messing ...
10
votes
5answers
5k views

“tar: unrecognized option --warning” during 'apt-get install'

I just ran apt-get upgrade on my debian 5 vps and I got this error: tar: unrecognized option `--warning=no-timestamp' Now when I try to install other packages e.g: imagemagick I get the same ...
9
votes
5answers
10k views

tar: Removing leading `/' from member names

root@server # tar fcz bkup.tar.gz /home/foo/ tar: Removing leading `/' from member names How can I solve this problem and keep the / on file names ?
9
votes
2answers
3k views

How to create a tar.gz file from a folder excluding a folder

How do I exclude a file or folder while creating a tar.gz file with tar command?
9
votes
6answers
8k views

tar + rsync + untar. Any speed benefit over just rsync?

I often find myself sending folders with 10K - 100K of files to a remote machine (within the same network on-campus). I was just wondering if there are reasons to believe that, tar + rsync + ...
9
votes
4answers
5k views

Create tar archive of a directory, except for hidden files?

Here's a newb question. I'm wanting to create a tar archive of a specific directory (with its subdirectories of course). But when I do it, using the tar command, I get a list of files that were ...
9
votes
2answers
858 views

What does “-” mean as an argument to a command?

I found this link on how to open tgz in one step. gzip -dc target.tar.gz | tar xf - What does the '-' mean?
9
votes
3answers
681 views

Universal extractors

With an increasing number of archive/compression file formats, is there a single free/open-source command line tool to rule them all? Perhaps something with a consistent / unified set of flags? (note ...
9
votes
2answers
1k views

Dereferencing hard links

In the manual page of tar command, an option for following hard links is listed. -h, --dereference follow symlinks; archive and dump the files they point to --hard-dereference follow ...
8
votes
2answers
2k views

Fastest way combine many files into one (tar czf is too slow)

Currently I'm running tar czf to combine backup files. The files are in a specific directory. But the number of files is growing. Using tzr czf takes too much time (more than 20 minutes and ...
8
votes
4answers
4k views

Rename directory inside of a tar archive

Is it possible to rename a directory inside of a tar archive? My use case is that I have an externally provided RPM spec file that assumes a tarball with a certain directory structure, and I have an ...
8
votes
4answers
104 views

Virtual write-only file system for storing files in archive

I have an embarrassingly parallel process that creates a huge amount of nearly (but not completely) identical files. Is there a way to archive the files "on the fly", so that the data does not consume ...
8
votes
1answer
4k views

How to check/test .tar.bz archives?

I've been using tar with its "--use-compress-prog=pbzip2" function to archive my files then compress them with pbzip2 to get an "*.tar.bz" archive. Afterwards I checked the resulting file with ...
7
votes
4answers
3k views

tar extraction depends on filename?

I often download tarballs with wget from sourceforge.net. The downloaded files then are named, e.g ...
7
votes
1answer
710 views

Under what circumstances does gunzip & tar xf work but tar xzf fail?

To illustrate the point: I have downloaded the LEDA library from the company's website. Using tar -xzf on it fails: $ tar -xzf LEDA-6.3-free-fedora-core-8-64-g++-4.1.2-mt.tar.gz tar: This does not ...
7
votes
3answers
1k views

Untar only a certain number of files from a large tarball

I have a large tarball that is busy being FTP'd over from a remote system to our local system. I want to know if it is possible to start untarring lets say 50 files at a time so that those files can ...
7
votes
2answers
4k views

How to create backup from symbolic links?

I have a directory with symbolic links to other directories. I want to archive the symbolic links, not as links but as archives containing the files of directories they refer to, using tar command. ...
7
votes
5answers
1k views

force copying a corrupted home directory

I have a home directory in a disk that has a lot of corrupted files. I am trying to save most files as possible. I am trying to create a backup of my home directory on an external drive using tar ...
6
votes
5answers
9k views

How can i view the contents of a tar.gz file (filenames + filesize)

I cannot use tar -tz as the solaris version I'm using does not accept the -z option. I tried something like gunzip file.tar.gz | tar -tv but that only gives: tar: /dev/rmt/0: No such file or ...
6
votes
3answers
376 views

How to convert tar file from gnu format to pax format

On the one hand I have a lot of tar files created with gnu format, and on the other hand I have a tool that only supports pax (aka posix) format. I am looking for an easy way to convert the existing ...
6
votes
4answers
2k views

howto inflate AND extract a .tar.bz2 using the 7-zip command line tool

I have a .tar.bz2 file that I want to be decompressed and extracted via the 7-zip commandline tool. So basically I'm looking for the equivalent of tar -xjf foo.tar.bz2 with 7-zip there is only the ...
6
votes
1answer
4k views

scp and compress at the same time, no intermediate save

What is the canonical way to: scp a file to a remote location compress the file in transit (tar or not, single file or whole folder, 7za or something else even more efficient) do the above without ...
6
votes
2answers
3k views

Can I automate tar's multi-volume-feature?

Ok, so I've just had a read through this page after a way to improve my current backup solution on my Debian server. Tar seems to be offering a quite nice multi-volume feature, although when I try it ...
6
votes
1answer
97 views

bash scripting - read tarball from stdin

I have a task I need to script that I feel should be stupidly simple, but I'm actually having a rather tough time. I have a short bash script that takes a specific type of application in tarball form ...
6
votes
2answers
141 views

How can I speed up operations on sparse files with tar, gzip, rsync?

I have a sparse file. (du -h reports 3G and du -h --apparent-size reports 100G.) So far, so good. Now, when I want to compress the file using tar or send it over the network using rsync, it will ...
6
votes
1answer
364 views

tar: how can I exclude intermediate directories but include leaf directories?

I want to create a tar file suitable for extracting into /. I've created a work directory that represents the root of the file system, and it has all the stuff I want included in the tar underneath, ...
5
votes
3answers
15k views

How do I extract with tar to a different directory?

This doesn't work: tar xf /tmp/foo.tar.gz foo/bar tar: foo/bar: Not found in archive It's not obvious to me what would do this beyond extracting it in place and moving the files over.
5
votes
3answers
700 views

What does the -f parameter do in the tar command

When using tar I always include -f in the parameters but I have no idea why. I looked up the man and it said; -f, --file [HOSTNAME:]F use archive file or device F (default "-", meaning ...
5
votes
4answers
3k views

Preventing tar from using too much CPU and disk (old laptop crashes if 100%)

I want to backup 1 terabyte of data to an external disk. I am using this command: tar cf /media/MYDISK/backup.tar mydata PROBLEM: My poor laptop freezes and crashes whenever I use 100% CPU or 100% ...
5
votes
2answers
2k views

If I change permissions on a tar file, will that apply to the files inside it?

I have a script that runs regularly via cron, that creates a tar.gz file for the purpose of backing up a directory. For reasons beyond my control, the only user who can execute the script via cron is ...
5
votes
3answers
961 views

Look at the tar log contents without extracting them

tar -tvf file.tar contains log files. Is there anyway to do something like this tar -tvf file.tar | head -1 | awk '{print $NF}' | xargs less {} This would give file not found, but is there a way? ...
5
votes
2answers
177 views

How is the order in which tar works on files determined?

$ touch dir/{{1..8},{a..p}} $ tar cJvf file.tar.xz dir/ dir/ dir/o dir/k dir/b dir/3 dir/1 dir/i dir/7 dir/4 dir/e dir/a dir/g dir/2 dir/d dir/5 dir/8 dir/c dir/n dir/f dir/h dir/6 dir/l dir/m dir/j ...
5
votes
3answers
2k views

How store in a variable a file list that includes the backslash when needed?

Main question: I am writing a script to perform a backup. I make a list of files in the following way: LISTOFFILES=$(find ~ \( -name '*.[pP][dD][fF]' -o -name '*.[oO][dD][tT]' \)) The variable ...
5
votes
2answers
484 views

What do these commands (`tar`) actually do? Is there a better way?

I am going over some documentation pertaining to creating a distro repo. However, I cannot understand exactly what these commands perform: # cd /mnt/ # ls centos-1 centos-2 centos-3 # for i in 1 2 ...
5
votes
3answers
1k views

Efficiently remove file(s) from large .tgz

Assume i have an gzip compressed tar-ball compressedArchive.tgz (+100 files, totaling +5gb). What would be the fastest way to remove all entries matching a given filename pattern for example ...
5
votes
2answers
6k views

tar with relative paths

I try to create an archive with tar using relative paths. I use the following command: tar czf ~/files/wp/my-page-order.tar.gz -C ~/webapps/zers/wp-content/plugins/ ...