Questions tagged [tar]

An archiving program for storing and retrieving files as a collection with support for data compression.

An archiving program for storing and retrieving files as a collection with support for data compression. It is mainly used for compacting multiple files into single one, for easy transporting or compression.

Its name comes from Tape ARchive

2690 questions
1075
votes
30 answers

Shell command to tar directory excluding certain files/folders

Is there a simple shell command/script that supports excluding certain files/folders from being archived? I have a directory that need to be archived with a sub directory that has a number of very large files I do not need to backup. Not quite…
deepwell
  • 20,195
  • 10
  • 33
  • 39
513
votes
22 answers

How do I tar a directory of files and folders without including the directory itself?

I typically do: tar -czvf my_directory.tar.gz my_directory What if I just want to include everything (including any hidden system files) in my_directory, but not the directory itself? I don't want: my_directory --- my_file --- my_file ---…
user4903
449
votes
9 answers

Tar a directory, but don't store full absolute paths in the archive

I have the following command in the part of a backup shell script: tar -cjf site1.bz2 /var/www/site1/ When I list the contents of the archive, I get: tar -tf…
QuentinC
  • 12,311
  • 4
  • 24
  • 37
297
votes
8 answers

Utilizing multi core for tar+gzip/bzip compression/decompression

I normally compress using tar zcvf and decompress using tar zxvf (using gzip due to habit). I've recently gotten a quad core CPU with hyperthreading, so I have 8 logical cores, and I notice that many of the cores are unused during…
user1118764
  • 9,255
  • 18
  • 61
  • 113
296
votes
5 answers

How to uncompress a tar.gz in another directory

I have an archive *.tar.gz How can I uncompress this in a destination directory?
Mercer
  • 9,736
  • 30
  • 105
  • 170
266
votes
1 answer

What is the difference between tar and zip?

What is the difference between tar and zip? What are the use cases for each?
mtk
  • 13,221
  • 16
  • 72
  • 112
234
votes
6 answers

Tar archiving that takes input from a list of files

I have a file that contain list of files I want to archive with tar. Let's call it mylist.txt It contains: file1.txt file2.txt ... file10.txt Is there a way I can issue TAR command that takes mylist.txt as input? Something like tar -cvf…
neversaint
  • 60,904
  • 137
  • 310
  • 477
221
votes
7 answers

Create a tar.xz in one command

I am trying to create a .tar.xz compressed archive in one command. What is the specific syntax for that? I have tried tar cf - file | xz file.tar.xz, but that does not work.
George K.
  • 2,867
  • 4
  • 19
  • 28
212
votes
1 answer

How do I turn off the output from tar commands on Unix?

I had a look at the options, but nothing seemed obvious as a manner in which to turn off the output when uncompressing a file. The below is the code I am currently using... I just need the option to switch off the output. tar -zxvf tmp.tar.gz -C…
h.l.m
  • 13,015
  • 22
  • 82
  • 169
161
votes
5 answers

Are tar.gz and tgz the same thing?

I created .tgz file with tar czvf file command.then I ended up with a tgz file. I want to know the difference between it and tar.gz.
mko
  • 21,334
  • 49
  • 130
  • 191
150
votes
10 answers

Excluding directory when creating a .tar.gz file

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…
suresh
  • 1,503
  • 2
  • 10
  • 4
136
votes
8 answers

How to check if a Unix .tar.gz file is a valid file without uncompressing?

I have found the question How to determine if data is valid tar file without a file?, but I was wondering: is there a ready made command line solution?
understack
  • 11,212
  • 24
  • 77
  • 100
132
votes
16 answers

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

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…
Micha
  • 1,321
  • 2
  • 8
  • 3
130
votes
9 answers

How to extract filename.tar.gz file

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
Kabir
  • 2,126
  • 5
  • 21
  • 24
116
votes
10 answers

Find files and tar them (with spaces)

Alright, so simple problem here. I'm working on a simple back up code. It works fine except if the files have spaces in them. This is how I'm finding files and adding them to a tar archive: find . -type f | xargs tar -czvf backup.tar.gz The…
Caleb Kester
  • 1,650
  • 2
  • 14
  • 16
1
2 3
99 100