tar

Ruby - Convert File to String

I need an easy way to take a tar file and convert it into a string (and vice versa). Is there a way to do this in Ruby? My best attempt was this: file = File.open("path-to-file.tar.gz") contents = "" file.each {|line| contents << line } I thought that would be enough to convert it to a string, but then when I try to write it back ou...

Which is the fastest TAR application?

I've got a script that tars an entire source code directory (around 800MB), and I want it to run as fast as possible. GNU Tar, for some reason, was kind of slow when untarring. I was wondering if anyone's already made this comparison and knows which application has the fastest tar/untar implementation. For Windows, btw. ...

How to use the tar -I option

I'm trying to tar up all the *.class files only on a Solaris box under a certain directory. Reading the man pages for tar made it seem like the -I option is what I wanted. This is what I've tried from the dir in question: find . -name "*.class" >> ~/includes.txt tar cvf ~/classfiles.tar -I ~/includes.txt From that I get: tar: Removi...

What are these stray zero-byte files extracted from tarball? (OSX)

I'm extracting a folder from a tarball, and I see these zero-byte files showing up in the result (where they are not in the source.) Setup (all on OS X): On machine one, I have a directory /My/Stuff/Goes/Here/ containing several hundred files. I build it like this tar -cZf mystuff.tgz /My/Stuff/Goes/Here/ On machine two, I scp the t...

How to resolve AIX tar command sockets errors?

Working in an AIX environment, I'm issuing the following tar command and receive errors on sockets. Question 1. How can I avoid the socket errors? Question 2. Can I rely on the tar file to contain all files excluding the ones in error? $ tar -cvf /post_patches.tar /xyz tar: /xyz/runtime/splSock6511 could not be archived tar...

How do I extract a tar file in Java?

How do I extract a tar (or tar.gz, or tar.bz2) file in Java? ...

Interesting usage of tar... but what is happening?

I saw the following interesting usage of tar in a co-worker's Bash scripts: `tar cf - * | (cd <dest> ; tar xf - )` Apparently it works much like rsync -av does, but faster. The question arises, how? -m EDIT: Can anyone explain why should this solution be preferable over the following? cp -rfp * dest Is the former faster? ...

caching a tar inside jvm for faster file I/O?

Hi, I'm working on a java web application that uses thousands of small files to build artifacts in response to requests. I think our system could see performance improvements if we could map these files into memory rather than run all over the disk to find them all the time. I have heard of mmap in linux, and my basic understanding of...

Linux how do I put double quotes around a file before piping it to tar?

I use ls to obtain my filename which has white space so it looks something like: my file with whitespace.tar.bz2 I want to pipe this to tar similar to: ls | grep mysearchstring | tar xvjf How can I insert double quotes before piping it to tar? ...

What is a good commercial tar stream lib for c# and .net?

We are currently using SharpZipLib but since it uses the GPL we need to replace it with a commercial lib. ...

Excluding .git in an Ant <tar> task

I'm using Ant 1.7.1 to tar up the contents of a directory, that contains a .git subdirectory. My current task is <tar destfile="sali-src-${version}.tgz" basedir="${basedir}" compression="gzip" excludes=".git, .gitignore, *.ipr, *.iws, *.iml"> </tar> But the resultant tarball contains the .git subdirectory. Could anybod...

What's a good tar utility for Windows?

I use Cygwin regularly, but I have a need these days to extract tar.gz and tar.bz2 files on other people's Windows machines. They don't want Cygwin; they need a GUI. I've tried 7-zip, which some other people in our company were using, but 7-zip makes the braindead decision to require you to first uncompress a file to a new destination ...

Why would a TAR file be smaller than it’s contents?

I have a directory I’m archiving: $ du -sh oldcode 1400848 $ tar cf oldcode.tar oldcode So the directory is 1.4gb. The file is significantly smaller, though: $ ls -l oldcode.tar -rw-r--r-- 1 ieure ieure 940339200 2002-01-30 10:33 oldcode.tar Only 897mb. It’s not compressed in any way: $ file oldcode.tar oldcode.tar: POSIX tar arch...

How can I archive a directory in Perl like tar does in UNIX?

I want to archive a directory (I don't know whether I can call "I want to tar a directory"). I want to preserve the access permissions at the other end when I un-tar it. I should I tackle this problem in perl. Thanks for the response but why I'm asking for doing it Perl is I want it independent of the platforms. I want to transfer one ...

Add last n lines of files to tar/zip

I need to regularly send a collection of log files that can grow quite large, so I would like to only send the last n lines of the each of the files. for example: /usr/local/data_store1/file.txt (500 lines) /usr/local/data_store2/file.txt (800 lines) Given a file with a list of needed files named files.txt, I would like to create an...

Overwritten file with tar

I was trying to tar a file and ended up overwriting it. I was working in Xcode and I'm wondering if there is a way for me to recover the overwritten file. ...

How to create a file of size more than 2GB in Linux/Unix?

I have this home work where I have to transfer a very big file from one source to multiple machines using bittorrent kinda of algorithm. Initially I am cutting the files in to chunks and I transfer chunks to all the targets. Targets have the intelligence to share the chunks they have with other targets. It works fine. I wanted to transfe...

How can I tar a file that is being used by another process?

I'm archiving a directory. This directory has a file that is being written by another process. When I tar this using Linux tar/Perl Tar module, in the archive the entry for the file is there but the contents are null. Before tarring the files are... -rw-r--r-- 1 irraju dba 28 Feb 18 02:22 a -rw-r--r-- 1 irraju dba 25 Feb 18 02:23 b ...

How do I preserve the setuid bit in tar archives with Perl's Archive::Tar?

I'm using Perl's Archive::Tar module. It preserves the file permissions but doesn't preserve the sticky bit. At the other end where I extract the archive, all the sticky bits are gone. I think UNIX/LINUX operating system stores these sticky bits somewhere else. How can I make my archive preserve sticky bits also? Using the -p switch to ...

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? ...