Questions tagged [tar]

0

votes
0

answer
3

Views

RPM Vs Tar based Installation

My knowledge on Linux administration is limited and hence wanted to check here about the pros and cons of installing any RHEL/CentOS Linux software using rpm packages over installing through tar/zip files. Thanks
greenhorntechie
1

votes
1

answer
1.7k

Views

How to convert tar.gz file to zip using Python only?

Does anybody has any code for converting tar.gz file into zip using only Python code? I have been facing many issues with tar.gz as mentioned in the How can I read tar.gz file using pandas read_csv with gzip compression option?
Geet
1

votes
1

answer
2.3k

Views

Extracting compressed files

The following code allows me to extract .tgz files. However, it stops extracting after about two levels down; there are other subfolders that have .tgz files that need extracting. Additionally, when I extract a file, I have to manually move it to another path or it will get overwritten by other .tgz...
suffa
1

votes
1

answer
1.6k

Views

java- library to extract/compress files from/ into archives

I am looking for a java library that extracts files from archives/ compresses files to create archives. Given below are my requirements-- (1) It should extract widest range/types of archives (2) Simple and requiring only few lines of code (unlike java's default zip class). (3) Production -grade: wi...
Arvind
1

votes
1

answer
2k

Views

How to netcat multiple files without tar?

Currently I am transporting files back and forth over telnet and I would like to send multiple files at once. However, my target platform (a Blackfin processor) does not have "tar" enabled in its kernel/busybox configuration (a uClinux distribution). As you all know the normal command is: nc -p 1234...
Anne van Rossum
1

votes
2

answer
583

Views

Tarring files exclude the path before the folder i want to tar

Im trying to tar a set of subfolders and then tar its parent folder afterwards via a ruby script. The structure is as follows: /x/y/z/ParentFolder/Subfolder1 /x/y/z/ParentFolder/Subfolder2 /x/y/z/ParentFolder/Subfolder3 /x/y/z/ParentFolder/Subfolder4 So what i want to end up with is Subfolder1.tar.g...
user1694873
1

votes
3

answer
2.3k

Views

get checksum of files inside tar archive on remote host

I succeed to obtain the md5sum of files inside archive without using file system thanks to : tar tjf '/home/adup/mybackup.tar.bz2' | sort | grep -v '/$' | ( while read filename; do md5=$(tar xjOf '/home/adup/mybackup.tar.bz2' $filename | md5sum | awk '{print $1}'); echo "$md5 $filename"; done) Unf...
ad_igs
1

votes
2

answer
1.1k

Views

create a tar.gz of a directory and clean up the directory except a file?

I would like to know if tar (1.15.1, Linux system) already has something like this before creating a script for it. I would like to create a dir.tar.gz of a given dir/ that contains a specific dir/myfile.gz. I would like the command to do 2 specific things: Preserve dir/myfile.gz Delete everything e...
719016
1

votes
2

answer
1.2k

Views

tar -cO | base64 output contains several hundred bytes of 'AAA' at the end [closed]

The permissions in the directories in which I am working are frequently too convoluted to use scp efficiently, so to copy files/folders between ssh sessions I've decided to cobble together tar and base64 for a ghetto solution. However, for some reason I'm getting a bunch of As padding at the end of...
Sammitch
1

votes
3

answer
335

Views

Specify destination for tarfile

Is there a way to specify where the tarfile needs to be created? The script needs to make a backup from "/home" and should save it in "/backup" My current code tarfile.open(output_filename, "w:gz") tar.add(input) tar.close() Thanks
David
1

votes
2

answer
317

Views

How does tar read files to create an archive?

What system call does tar use to get the content of files that it uses to create an archive? I tried using strace to see the call, but it never calls open on the file. $ echo "HelloWorld" > my_test_file $ strace -s250 -f -F tar -cf /dev/null my_test_file 2>&1 | grep my_test_file execve("/bin/tar",...
onionjake
1

votes
2

answer
1k

Views

Python: Assign a compression level to tarfile

My question is a follow up to this one. I would like to know how I can modify the following code so that I can assign a compression level: import os import tarfile home = '//global//scratch//chamar//parsed_data//batch0' backup_dir = '//global//scratch//chamar//parsed_data//' home_dirs = [ name for n...
Plug4
1

votes
1

answer
3.2k

Views

tar returns 1 in script, but not interactively

If I run the following shell script (ie tar file then delete source if it is successful) #!/bin/bash tar cvf /home/acampton/vortex_data/2014-02-14/tmp-2014-02-14-test2.tar -C /home/acampton/vortex_data/2014-02-14 SIC_17_RADAR-2014-02-14_all_no_dups.csv if [ $? -ne 0 ]; then then echo "Deleting fi...
user3321283
1

votes
1

answer
438

Views

maven-assembly-plugin generates tar incompatible with python's tarfile (works with bsdtar)

As part of an automated deployment pipeline I'm creating a tar.gz file with the maven-assembly-plugin then unpacking it with python's tarfile module. The extraction fails with the exception: Traceback (most recent call last): File "tarfile-assembly-testcase/extract_tar.py", line 20, in tarfile.open...
logic.town
1

votes
1

answer
1.7k

Views

Unable to extract tar file - tar: extract not authorized

I am working on Solaris 10 machine. In that i cannot able to untar my file. Logs are given below. Anyone please suggest what may be the issue? I can able to create tar file but unable to untar. :( bash-3.2# ls -lrth ConfigCheck-120614-KL.out* -rw-r--r-- 1 root root 144K Jun 12 17:15 ConfigCheck-1206...
gyrous
1

votes
3

answer
9.6k

Views

untar all .gz in directories and subdirectories

For starters I have checked most of the solutions available no How to untar all .tar.gz with shell-script? Unzipping multiple zip files in a directory? I have a directory that has subdirectories with .gz files in them, and would like to extract all into either one folder or just keep them in their f...
user3862515
1

votes
1

answer
1.2k

Views

Untar (.gz) a file on the as400?

My google fu seems to fail me - or maybe it's just the delightful amount of fantastic information there is available on the IBM Power/iSeries/as400 beast. In any case, I have a .tar.gz file on this machine. When I fire up qsh and run tar -xzvf mytarfile.tar.gz it doesn't run 'cause there's no z flag...
Wayne Werner
1

votes
1

answer
279

Views

git archive preserve time

I have some files in my git repo ... -rw-r--r-- 1 dimti dimti 11489 мар 2 21:54 wp-settings.php ... After execute command git archive --format=tar HEAD > repo.tar I fetch my files in tar-archive, but modify time is wrong: -rw-r--r-- 1 dimti dimti 11115 мар 5 21:55 wp-settings.php How to sa...
Alexander Demidov
1

votes
2

answer
846

Views

How can I convert .tar to .tgz

I'm trying to compress some files with python. I'm using subprocess, the problem is that I don't know how to compress all the files. Here is what I do: comand = czf saveFolder = /home/albert/a.tgz temporal = /home/albert/test1 subprocess.call(["tar",comand,saveFolder,temporal]) How can I add more fi...
user2911701
1

votes
1

answer
460

Views

why does this tar command fail when passed as string in ssh call?

ssh [email protected] "sudo tar -czf - -C /path/To/Directory *.properties" | tar xzf - It fails with following error - tar: *.properties: Cannot stat: No such file or directory tar: Exiting with failure status due to previous errors If I ssh to server and then on server, instead of tar -czf - use tar -cz...
Ani
1

votes
1

answer
1.4k

Views

Exclude base directory inside Gradle tar/zip artifacts

The maven assembly plugin has an includeBaseDirectory option that (when set to false) avoids having a single top-level directory inside the tar/zip artifact with the same name as the artifact itself. I'd like to achieve the same result with Gradle, but I don't see how. I'm using a configuration lik...
Justin Lewis
1

votes
1

answer
4.3k

Views

Can't extract .xz files with python “tarfile.ReadError: file could not be opened successfully”

I need to extract some text files compressed to .xz files using python. My code is just import tarfile tarfile.open('file.xz') But this fails with the error Traceback (most recent call last): File "", line 1, in File "/usr/lib/python3.4/tarfile.py", line 1558, in open raise ReadError("file could...
Qwertie
1

votes
1

answer
20

Views

tar extracted archive removes version

I have a zipped archive version 0.0.1: myarch_0.0.1.tar.gz When I extract it with tar, everything is unzipped and extracted in a myarch folder, stripping the version number. ls myarch_0.0.1.tar.gz tar -zxvf myarch_0.0.1.tar.gz ls myarch/ myarch_0.0.1.tar.gz* I want the extracted folder to be named:...
kaligne
3

votes
1

answer
555

Views

bash, getting the mime type of a file handle

How would i get the mime type of a file-handle without saving it to disk? What i mean is a file that is not saved to disk, rather: i extracted it from an archive and plan on piping it to another script. Say i extracted the file like this: tar -xOzf images.tar.gz images/logo.jpg | myscript Now insid...
dovidweisz
1

votes
3

answer
751

Views

How to extract a variety of zip files without knowing the extension in bash

I'm writing a bash script which needs to handle a bunch of zip files with different possibilities (primarily tar.gz, zip, and rar). Is there a tool I can get that does this, so I could call "toolname filename", and if not, how do I determine the extension of a file (so that I can make a case stateme...
user3475234
1

votes
2

answer
4.6k

Views

How to find all tar files in various sub-folders, then extract them in the same folder they were found?

I have lots of sub-folders, with only some containing a tar file. i.e.: folder1/ folder2/this-is-a.tar folder3/ folder4/this-is-another.tar I can find which dirs have the tar by simply doing ls */*.tar. What I want to achieve is somehow find all .tar files, then extract them in the same directory t...
user1942651
2

votes
2

answer
3.3k

Views

Makefile: dependencies on directory content when creating a tar file

In my battle against .PHONY targets I re-wrote: # Makefile v0 tar: tar -cf tarfile.tar dir .PHONY: tar to be: # Makefile v1 tar: tarfile.tar tarfile.tar: $(shell find dir) tar -cf [email protected] dir .PHONY: tar Which seems to work for a toy example. However, I can see that this might do the wrong thing, dependi...
Chen Levy
2

votes
2

answer
6.5k

Views

How to print the content of a tar.gz file with Java?

I have to implement an application that permits printing the content of all files within a tar.gz file. For Example: if I have three files like this in a folder called testx: A.txt contains the words "God Save The queen" B.txt contains the words "Ubi maior, minor cessat" C.txt.gz is a file compres...
Bomberlatinos9
1

votes
3

answer
2.8k

Views

how to create .tar file on windows OS? [closed]

I am using window OS. I have a folder named as myFolder which contains many files, I need to convert that myFolder to myFolder.tar file. Anyone please suggest how to do it?
1

votes
2

answer
88

Views

How do I set case for tar, gz and tar.gz files?

I have few files in a directory like this: xxx.tar.gz xxx.tar yyy.tar.gz yyy.tar zzz.txt.gz ... ... I have list.txt for files like this: list.txt: /home/phe/xxx.tar.gz /home/phe/xxx.tar /home/phe/yyy.tar.gz /home/phe/yyy.tar /home/phe/zzz.txt.gz ... ... I need to extract these files like this: for f...
phe
2

votes
1

answer
444

Views

Bash script exits with no error

I have a bash script that I'm running from DVD. This script copies multi-volume tar files from DVD to the local machine. Part-way through the copy, the script prompts the user to insert a second DVD, at which point the remaining files are copied. The script exists on the first DVD but not on the sec...
LousyG
2

votes
1

answer
71

Views

Modificate files inside zip file , other way

I need know if its possible other way ............ i try modificate some files inside zip file , i try this using class zip and works $zip = new ZipArchive; $res = $zip->open('test.zip'); if ($res === TRUE) { $zip->extractTo('./', 'test.txt'); $fp=fopen("test.txt","a"); fputs($fp,"Hello"."\n"); fclo...
user3626084
1

votes
1

answer
23

Views

Combination of tar and head -1 not working as expected

I am working on a script that needs to decompress a file and then switch to the first folder decompressed using cd comment. What I do is the following: filename_2=$(tar zxvf ${filename} | head -1) cd $filename_2 And works as expected, but it doesn't decompress all of the files from the tar.gz file...
DDDDEEEEXXXX
17

votes
2

answer
4.2k

Views

Why is Java 7 Files.walkFileTree throwing exception on encountering a tar file on remote drive

Im using Files.WalkFileTree() to navigate folder and counting audio files, but there is a problem when it encounters a tar file, it seems to be treating it as an actual folder I was expecting it to just skip over it. I cannot see any options that let me control this behaviour Code: package com.jthi...
Paul Taylor
17

votes
3

answer
11.4k

Views

Ruby: Create A Gzipped Tar Archive

What's the best way to create a gzipped tar archive with Ruby? I have a Rails app that needs to create a compressed archive in response to user actions. Ideally, it would be possible to write directly to a compressed file without needing to generate intermediate temp files first. The Ruby Zlib libra...
Rich Apodaca
0

votes
0

answer
3

Views

showing status with large file transfers via netcat/nc

I am using nc/netcat to transfer a large tar stream. Is there a way for either side to show some kind of status? Like how much has been transferred and/or the speed while it is transferring? On the receiving end: nc -l 9000 > data.tar On the sending end: tar cf - -C /path/to/data files | nc -N [targ...
IMTheNachoMan
17

votes
4

answer
16.1k

Views

Compare tar file of the directory with the original directory

How can I compare a tar file (already compressed) of the original folder with the original folder? First I created archive file using tar -kzcvf directory_name.zip directory_name Then I tried to compare using tar -diff -vf directory_name.zip directory_name But it didn't work.
Steve
1

votes
1

answer
207

Views

Extracting Single from huge Archive using Perl

I'm trying a single from a large ".tgz" file. I'm using Archive::Tar::Streamed module. Here is the sample code. my $tar2 = Archive::Tar::Streamed->new($filename); $fil = $tar2->next; while($fil) { $_ = $fil->name; if(m/abc\.txt/g) { $fil->extract($outpath); $fil = $tar2->next; } } But the iterator i...
wesfaith
1

votes
2

answer
5.4k

Views

Can't unzip Chef cookbooks on Windows Command Line - 'tar' not recognized

Unfortunately stuck using Windows command line as opposed to Linux bash... When installing chef cookbooks from command line using knife cookbook site install COOKBOOK the COOKBOOK.tar.gz file will download but won't extract. How can I make this happen in Windows Command line? The error messa...
csi
17

votes
3

answer
12.5k

Views

Unix tar: do not preserve directory structure

When I try to compress files and directories with tar using absolute paths, the absolute path is preserved in the resulting compressed file. I need to use absolute paths to tell tar where the folder I wish to compress is located, but I only want it to compress that folder – not the whole path. For...

View additional questions