Questions tagged [tar]
The tar archive format and/or the command-line utility for working with tar files.
1,275
questions
4
votes
2
answers
170
views
Can I store and work with a directory in compressed form?
I have to work with many large sized directories which are shipped around in the form of tarballs. However, in order to really do any operations these tarballs have to be untarred into directories and ...
4
votes
1
answer
938
views
Is it possible to get file list, byte range from the head of a tar+bzip2 file?
Essentially, I'm hoping someone with an advanced knowledge of tar/bz2 can answer whether this is possible.
The situation is that we have a periodic 24GB feed of data from a vendor, as a .tbz file. (...
4
votes
1
answer
23k
views
tar broken pipe error [closed]
I'm using tar to backup my entire file system with the following command
tar -cvpzf test/backup.tar.gz / --exclude=/test
And I'm getting the following error
tar: test/backup.tar.gz: Cannot write: ...
4
votes
2
answers
376
views
Resumable archive
I've a need to archive some big directory structures on an NFS server. They're not likely to be needed particularly soon, if ever - they're just being retained for policy reasons.
To this end, I'm ...
4
votes
2
answers
2k
views
command to get topmost directory name in compressed files
Filenames are ones shown below, but the directory will be libgit2-0.21-1 when tar xvf v0.21.1.tar.gz, so how use one-liner to get the directory name(report error if more than two directory exist):
...
4
votes
1
answer
2k
views
How to create a deterministic tar.gz using git-archive?
Creating a git repository for testing.
~ $ mkdir somefolder
~ $ cd somefolder/
~/somefolder $ git init
Initialized empty Git repository in /home/user/somefolder/.git/
~/somefolder $ echo test > ...
4
votes
2
answers
974
views
unable to back-up data from android tablet to laptop using tar!
I'm using tar to back-up data from my android tablet to laptop. But it is showing some error.
ravbholua@ravbholua-Aspire-5315:/run/user/ravbholua/gvfs/mtp:host=%5Busb%3A002%2C003%5D/65537/9$ tar -cvf ...
4
votes
1
answer
5k
views
Create or Update if exists tar file
I ran into that problem today when I wanted to tar all files and directories in a specified directory. Doing the following is not enough because hidden files (ones starting with . won't be included):
...
4
votes
1
answer
3k
views
tar: compress text stdin and stdout [duplicate]
Using tar, is it possible to compress stdin text and have the compressed data appear in stdout? Example:
$ echo "test" | tar c -
<compressed blob here>
I'm using macOS Mojave.
4
votes
2
answers
3k
views
create flat tar archive: ignoring all parents when adding folders
I want to add a few folders (recursively) to a new tar archive. All of the folders should be at the root level of the resulting archive. Is there any way to add all folders without their parents, and ...
4
votes
5
answers
4k
views
Include subdirectory from excluded directory in a tar archive
I have the root folder USA and sub-folders California and Texas. Texas is an excluded sub-folder but it has a specific file in it that I'd like to include in the tar backup. Let's call this file ...
4
votes
1
answer
636
views
Can tar discover the archive format when piping it in via wget?
When I have a tar archive of any format, I can use:
tar xf archive.tar.xz
tar xf anotherarchive.tar.gz
as tar discovers the relevant format by itself.
Now I want to download the archives and ...
4
votes
2
answers
680
views
Make Tar Incremental Backups into One Backup?
Well, I know this question is quite strange. I have done a lot of incremental backups. Now the total file size gets too large, because there are a lot of duplicate files with similar contents, and ...
4
votes
1
answer
1k
views
HP-UX 9: Backup filesystem using tar
So I've got an HP-UX 9 box that I'm trying to backup, first to a tape with fbackup, to no avail, and now to a folder shared over NFS. I'm using the command "tar -cvf /nfs/Results/backup.tar /" where ...
4
votes
2
answers
1k
views
Compose and pipe a gzipped tar archive in one go
I'm trying to come up with an effective way to create a gzipped archive of various system partitions on Android, piping everything out to stdout so as to be able to encrypt it as it comes across via ...
4
votes
2
answers
7k
views
How do I dereference links when extracting from a tar file?
If I have a tar file, bob.tar, which contains real_file and link_to_real_file, in which the latter is a symlink, is there a way to extract the contents of bob.tar so that link_to_real_file will not be ...
4
votes
1
answer
629
views
GNU `tar` runs `stat` on an excluded directory. Is it normal?
I'm running tar as root like this:
cd /
tar --create \
--verify \
--exclude-backups \
--exclude-caches \
--auto-compress ...
3
votes
3
answers
4k
views
How do I pipe the output of tar through mv?
A previous question of mine asked how to pipe downloaded files through tar, now I would like to know how to pipe the output of tar through mv. See I have this command at the moment:
wget -c https://...
3
votes
2
answers
22k
views
want to exclude multiple folders and files when extracting using tar
I would like to extract from a tar file (20G) and exclude many files and folders during the restore. I know how to exclude one or few files/folders but my list is in hundreds which I want to exclude. ...
3
votes
2
answers
1k
views
pipe of tar and tree commands?
I would like to see the tree of a big compressed file (specifically only the second level of directories) so I used the following command:
tar -tf tarfile | tree -L 2
But it outputs the tree of the ...
3
votes
2
answers
13k
views
Extract specific directories with all subdirectories from a tar file
I know how to extract single file from a tarball, although now I have 500 GB tar file without any compression, just a plain tar and I would like to extract specifically 3 directories, with such ...
3
votes
1
answer
2k
views
How does pv work?
How does the following command work?
pv file.tar.gz | tar -xz
From my understanding the pipe operator | creates a pipe and stdout of pv is mapped to the O_WRONLY end of the pipe and tar's stdin is ...
3
votes
3
answers
12k
views
Delete everything before last slash in bash variable
I have a variable myVar in bash containing a long string that looks like this:
-rw-rw-rw- root/root 16 2018-02-12 10:03 foo_tar/baz1234_
I want to delete everything in myVar before the last slash (...
3
votes
2
answers
2k
views
How to use globs/wildcards when the -C option is used in tar command?
My directory structure is as follows :
/home/workspace/build/
/home/workspace/js/jai.1.js
/home/workspace/js/jai.2.js
/home/workspace/js/jai.3.js
/home/workspace/js/jai.4.js
I want to tar all js ...
3
votes
3
answers
8k
views
untar a directory of *.tgz files using a wildcard
I've got a directory that looks like
$ ls
Broad_hapmap3_r2_Affy6_cels_excluded.tgz DINGO.tgz GIGAS.tgz index.html IONIC.tgz passing_cels_sample_map.txt ...
3
votes
1
answer
867
views
Why is it so that when tar is executed from the script I get "command not found", (it runs without giving me such output from the terminal)?
The following script does the job of archiving /home/jerzy/testdir/:
#!/usr/bin/bash
XZ_OPT=-9 tar -cJf /home/jerzy/testdir.tar.xz -C /home/jerzy testdir && \
echo "testdir/ already ...
3
votes
5
answers
3k
views
Create archive (tar.gz, ...) from file given via stdin
I would like to automatically create a compressed archive from a file given via stdin (or create the archive, if it doesn't exist yet), while specifying the file name that it's going to have inside ...
3
votes
1
answer
2k
views
tar without -f option in extraction
My question is similar to the question What does the -f parameter do in the tar command, but it pertains to archive extraction. If I issue tar x instead of tar xf mytarball.tar, is it expecting I "...
3
votes
4
answers
817
views
Avoid the contents of a .tar begin with './'
I want to make a backup of a directory using tar and xz, but I have a problem. When I open the file, all the files and directories begin with ./ and I don't want this to happen.
file.tar.xz
|---- ...
3
votes
1
answer
2k
views
"tar --exclude-backups" does not exclude files with tilde at end
If I have the following directory:
$ ls -a foo
. .. a #a# a~ b b.bkp c .git .hg .svn
and call:
$ tar zcf foo-no-bkp.tar.gz --exclude-backups foo/
The resulting archive still has backup ...
3
votes
2
answers
824
views
Tarring-gzipping only hidden directories (or files + directories)
Based on this, to tar all hidden files in the current directory one can use
ls -A | egrep '^\.' | tar cvf ./test.tar -T -
However, how can one tar only all hidden directories or all hidden directories ...
3
votes
2
answers
26k
views
tgz file give invalid compressed data--format violated [closed]
I have download this file
http://download.icu-project.org/files/icu4c/55.1/icu4c-55_1-HPUX11iv3-aCC.tgz
https://ssl.icu-project.org/files/icu4c/55.1/icu4c-bin-55_1.md5
md5sum ok
But on linux and ...
3
votes
2
answers
2k
views
Tell gzip/bzip2/7z/etc not to compress already-compressed files?
I'm tarring up /home, and piping it through bzip2. However, I've got lots of already-compressed files out there (.jpg, .mp4, .mkv, .webm, etc) which bzip2 shouldn't try to compress.
Are there any ...
3
votes
3
answers
15k
views
Backup files with tar command and progress bar? [duplicate]
Can I see a progress bar or something not only ust the terminal screen output while backing up?
Here is my shell script that I used backup with tar command:
# !/bin/bash
DATEJOUR=$(date +"%Y-%m-%...
3
votes
1
answer
3k
views
tar and if-statement
I have a script that check if a file exist inside a tar file but something's wrong because it always go to the else part of the script. I am pretty sure that it shouldn't be that way.
The date is in "...
3
votes
1
answer
3k
views
Error handling with tar and keep-old-files option
I am unpacking tar files with the --keep-old-files option so that I don't clobber files that are already there. The annoying thing is that this causes tar to produce an error code #2 (fatal error) ...
3
votes
1
answer
1k
views
tar: exclude gzip file, and don't try to gunzip it
I would like to skip a large gzip file when I extract a tar file, but everytime tar starts to gunzip it to look inside it seems.
Even when I just try to peek inside tar seems to start gunzipping it, ...
3
votes
3
answers
1k
views
How to create split tar archive in multiple stages to save space?
I have a very large folder that I am trying to create a tar archive of. The issue is I don't have enough extra free space to store the entire archive so I want to create say 100-200GB chunks of the ...
3
votes
3
answers
26k
views
LINUX: tar: You may not specify more than one '-Acdtrux', '--delete' or '--test-label' option [closed]
sudo tar xuzf splunk-7.2.4-8a94541dcfac-Linux-x86_64.tgz -C /opt
I get the following message:
tar: You may not specify more than one '-Acdtrux', '--delete' or '--test-label' option
Try 'tar --help' ...
3
votes
3
answers
15k
views
tar (child) error
I'm trying to backup my entire VM on Fedora Linux. I'm using the following command
tar -cvpzf / test/backup.tar.gz --exclude=/test
But when I do that, I come up with this error:
tar (child): /: ...
3
votes
5
answers
4k
views
How do I install downloaded software using package managers? (Ubuntu Linux)
I recently learned that linux does not have any installation wizards.
I needed the following software, so I downloaded them and put them in a folder.
As you can see, I've extracted one of them.
Now, ...
3
votes
3
answers
2k
views
Archiving to remote-machine with tar/cpio and ssh?
I'm renting a couple of VPS with Ubuntu, and I've managed to fill-up one of them. Here I've got several directories with lots of files I'd like to put into an archive. Unfortunately, I don't have ...
3
votes
1
answer
8k
views
Uncompressing .tar.gz archive to specific directory [duplicate]
How does tar.gz file gets uncompressed with all contents to arbitrary directory, existing or not using tar using single line command? If it does not exists, then is created (directory). To clarify, ...
3
votes
1
answer
10k
views
How to pipe scp/ssh file transfer(pull) through tar (remote->local transfer initiated from local machine)
I would like to pipe an scp pull operation(sample without tar below) through tar, so that only one tar file is written for about 10 directories:
user@localhost:/home/user> scp -r remoteuser@...
3
votes
1
answer
34k
views
How to show a progress bar while tar a folder recursively?
In bash-script execution of taring not shown a progress bar, how to show a progress bar while taring a directory?
3
votes
3
answers
8k
views
tar append to file in archive
Good morning,
I have a tar compressed archive tar.bzip2 (created using tar jcf), which contains a file named data.txt (1).
On the other side, I have another file also named data.txt (2).
Is ...
3
votes
1
answer
4k
views
cpio VS tar - what the best archive solution in order to compress hundred of directories to one file
I have hundreds of directories under /var/Recording, and each directory there will have subdirectories, including files, hard links and soft links.
I want to compress all directories under /var/...
3
votes
3
answers
1k
views
Different count for compressed file listing vs directory listing
I was taking a backup of a folder, where I used the following command :
sudo tar -zcvf www.tar.gz /var/www/
It successfully compressed, just for verifying the number of files in the compressed ...
3
votes
1
answer
116
views
tar files with backslahes on Debian
I need to copy files that contain (Windows-style) backslahes from a Debian 10 pod. I'm having trouble with GNU tar 1.30 archiving files with backslashes:
docker run --rm -it debian:10 bash
inside the ...
3
votes
2
answers
188
views
Appending directory name to contents of tar.gz directory in the shell
I have a directory of compressed directories, like this:
MainDirectory/FolderA.tar.gz
MainDirectory/FolderB.tar.gz
Within each directory, some of the files have the same name. Ex.
MainDirectory/...