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
113
votes
11 answers

How do I tar a directory without retaining the directory structure?

I'm working on a backup script and want to tar up a file directory: tar czf ~/backup.tgz /home/username/drupal/sites/default/files This tars it up, but when I untar the resulting file, it includes the full file structure: the files are in…
Brock Boland
  • 15,870
  • 11
  • 35
  • 36
113
votes
8 answers

How to tar certain file types in all subdirectories?

I want to tar and all .php and .html files in a directory and its subdirectories. If I use tar -cf my_archive * it tars all the files, which I don't want. If I use tar -cf my_archive *.php *.html it ignores subdirectories. How can I make it tar…
user1566515
  • 1,637
  • 4
  • 17
  • 25
110
votes
3 answers

Create a .tar.bz2 file Linux

On my Linux machine, I wish to create a .tar.bz2 file of a certain folder. Once I place myself in that folder (in the terminal), what do I type in the terminal command line to place the compressed folder in the home directory of my machine? Let's…
Adam
  • 2,384
  • 7
  • 29
  • 66
105
votes
5 answers

reading tar file contents without untarring it, in python script

I have a tar file which has number of files within it. I need to write a python script which will read the contents of the files and gives the count o total characters, including total number of letters, spaces, newline characters, everything, …
randeepsp
  • 3,572
  • 9
  • 33
  • 40
104
votes
7 answers

I want to create a script for unzip (.tar.gz) file via (Python)

I am trying to make a script for unzipping all the .tar.gz files from folders in one directory. For example, I will have a file which it calls ( testing.tar.gz). Then if I do manually, I can press to "extract here" then the .tar.gz file will create…
Alex
  • 1,097
  • 2
  • 9
  • 12
103
votes
10 answers

tar: file changed as we read it

I am using make and tar to backup. When executing makefile, tar command shows file changed as we read it. In this case, the tar package is ok when the warning comes up but it stops the tar command for the following backup the file showing the…
warem
  • 1,471
  • 2
  • 14
  • 21
102
votes
5 answers

How do I extract files without folder structure using tar

I have a tar.gz-file with the following structure: folder1/img.gif folder2/img2.gif folder3/img3.gif I want to extract the image files without the folder hierarchy so the extracted result looks like: /img.gif /img2.gif /img3.gif I need to do this…
Ben Jackson
  • 1,427
  • 3
  • 14
  • 24
92
votes
9 answers

gzip: stdin: not in gzip format tar: Child returned status 1 tar: Error is not recoverable: exiting now

I have a Bash script that creates a .tar.gz file, encrypts, and then sends it to a drive. However, I cannot open the .tar.gz file afterwards. Here is my process... Bash script that encrypts. #!/bin/sh # Tar the automysqlbackup directory tar -zcf…
ServerSideSkittles
  • 2,713
  • 10
  • 34
  • 60
90
votes
3 answers

Uncompress tar.gz file

With the usage of wget command line I got a tar.gz file. I downloaded it in the root@raspberrypi. Is there any way to uncompress it in the /usr/src folder?
dali1985
  • 3,263
  • 13
  • 49
  • 68
85
votes
3 answers

How can you untar more than one file at a time?

I have a bunch of tar files in a directory and I want to extract all the files from them at once. But this doesn't seem to do anything: $ tar xf *.tar What's going on here? How do I untar a bunch of files at once?
Jon 'links in bio' Ericson
  • 20,880
  • 12
  • 98
  • 148
81
votes
1 answer

How to extract a single file from tar to a different directory?

I know that I can use following command to extract a single file to the current working directory (assume I have a tar file named test.tar and a file named testfile1 and testfile2 are inside it): $tar xvf test.tar testfile1 And I can use -C option…
MengT
  • 1,207
  • 2
  • 14
  • 16
81
votes
7 answers

Check the total content size of a tar gz file

How can I extract the size of the total uncompressed file data in a .tar.gz file from command line?
Ztyx
  • 14,100
  • 15
  • 78
  • 114
81
votes
7 answers

How can I build a tar from stdin?

How can I pipe information into tar specifying the names of the file?
Kristopher Ives
  • 5,838
  • 7
  • 42
  • 67
80
votes
6 answers

Listing the content of a tar file or a directory only down to some level

I wonder how to list the content of a tar file only down to some level? I understand tar tvf mytar.tar will list all files, but sometimes I would like to only see directories down to some level. Similarly, for the command ls, how do I control the…
Tim
  • 1
  • 141
  • 372
  • 590
80
votes
6 answers

How can files be added to a tarfile with Python, without adding the directory hierarchy?

When I invoke add() on a tarfile object with a file path, the file is added to the tarball with directory hierarchy associated. In other words, if I unzip the tarfile the directories in the original directories hierarchy are reproduced. Is there a…
theactiveactor
  • 7,314
  • 15
  • 52
  • 60