<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title>Tech-Recipes - Latest Comments in Tar and compress a file in one step</title><link>http://tech-recipes.disqus.com/</link><description>Cookbook of Tech Tutorials</description><atom:link href="https://tech-recipes.disqus.com/tar_and_compress_a_file_in_one_step/latest.rss" rel="self"></atom:link><language>en</language><lastBuildDate>Thu, 29 Apr 2010 08:12:50 -0000</lastBuildDate><item><title>Re: Tar and compress a file in one step</title><link>http://www.tech-recipes.com/rx/64/tar-and-compress-a-file-in-one-step/#comment-47390312</link><description>&lt;p&gt;To Compress !&lt;br&gt;tar cjf &amp;lt;archive_name&amp;gt;  /dir1 file1 /dir2 .... /dirN  /fileN   =&amp;gt; For Bunzip&lt;/p&gt;&lt;p&gt;tar czf &amp;lt;archive_name&amp;gt;  /dir1 file1 /dir2 .... /dirN  /fileN   =&amp;gt; For Gunzip&lt;/p&gt;&lt;p&gt;You can always use &lt;br&gt;"man tar" when you need help !&lt;/p&gt;&lt;p&gt;To Extract/uncompress , replace the "c" with "x" in the above commands !&lt;br&gt;Thanks ,&lt;br&gt;Danny&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">dannyntui</dc:creator><pubDate>Thu, 29 Apr 2010 08:12:50 -0000</pubDate></item><item><title>Re: Tar and compress a file in one step</title><link>http://www.tech-recipes.com/rx/64/tar-and-compress-a-file-in-one-step/#comment-34195142</link><description>&lt;p&gt;How do you uncompress this in one step?&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">GlobalNerds</dc:creator><pubDate>Sun, 14 Feb 2010 14:27:37 -0000</pubDate></item><item><title>Re: Tar and compress a file in one step</title><link>http://www.tech-recipes.com/rx/64/tar-and-compress-a-file-in-one-step/#comment-21832550</link><description>&lt;p&gt;You can use gtar instead&lt;/p&gt;&lt;p&gt;gtar -cvzf target output.tgz&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Vinayak Kamath</dc:creator><pubDate>Wed, 04 Nov 2009 00:21:43 -0000</pubDate></item><item><title>Re: Tar and compress a file in one step</title><link>http://www.tech-recipes.com/rx/64/tar-and-compress-a-file-in-one-step/#comment-14982907</link><description>&lt;p&gt;Or 'tar zcf target.tgz'  Most tar versions have had built in gzip function for over a decade at least.  Over ssh it would be ssh blah@blah 'tar zcf -' &amp;gt; target.tgz&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">fusiondog</dc:creator><pubDate>Mon, 17 Aug 2009 18:20:09 -0000</pubDate></item><item><title>Re: Tar and compress a file in one step</title><link>http://www.tech-recipes.com/rx/64/tar-and-compress-a-file-in-one-step/#comment-7111446</link><description>&lt;p&gt;it would be:&lt;/p&gt;&lt;p&gt;tar -cf - /home/eaips/var/fileName | gzip -c &amp;gt; /home/eaips/var/fileName.tar.gz&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Quinn McHenry</dc:creator><pubDate>Wed, 11 Mar 2009 17:11:34 -0000</pubDate></item><item><title>Re: Tar and compress a file in one step</title><link>http://www.tech-recipes.com/rx/64/tar-and-compress-a-file-in-one-step/#comment-7107346</link><description>&lt;p&gt;I have following two steps in my script, how club them and do it in a single step ?&lt;/p&gt;&lt;p&gt;tar  -cf  /home/eaips/var/fileName.tar  /home/eaips/var/fileName&lt;br&gt;gzip /home/eaips/var/fileName.tar&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Satish</dc:creator><pubDate>Wed, 11 Mar 2009 14:40:21 -0000</pubDate></item><item><title>Re: Tar and compress a file in one step</title><link>http://www.tech-recipes.com/rx/64/tar-and-compress-a-file-in-one-step/#comment-2766830</link><description>&lt;p&gt;If  you wanna try something a little bit funnier, tar and zip a file, then unzip and untar it in another directory in only one step (this is usefull to keep symlinks unchanged)&lt;/p&gt;&lt;p&gt;tar -cvf - mySelection | gzip -c  | (cd myNewDirectory ; gzip -dc | tar xvf -)&lt;/p&gt;&lt;p&gt;make this match to your own needs...&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Hseb72</dc:creator><pubDate>Thu, 14 Oct 2004 05:21:21 -0000</pubDate></item><item><title>Re: Tar and compress a file in one step</title><link>http://www.tech-recipes.com/rx/64/tar-and-compress-a-file-in-one-step/#comment-2766829</link><description>&lt;p&gt;Although this probably belongs under the OpenSSH section, this is a really neat trick for snapping a tarball of a machine with limited diskspace, and storing the output on your workstation (or machine that your SSH'ing from).&lt;/p&gt;&lt;p&gt;You must already have the hostkey from the remote machine (i.e., logged in at least once) otherwise this will fail.  SSH allows you to connect to a remote machine and pass a commandline rather than firing up an interactive shell.  The output is then dumped to your local console for further processing.&lt;/p&gt;&lt;p&gt;Before you scratch your head, think of this.  You have a machine that has virtually no space left (or at least, not enough to make that tarball).  qmchenry's post shows you how to get tar to spool the archive to stdout:&lt;/p&gt;&lt;p&gt;&lt;code&gt;&lt;br&gt;tar -cf - target&lt;br&gt;&lt;/code&gt;&lt;/p&gt;&lt;p&gt;What if you can capture that to your own workstation, which probably has ample space.   Picture this:&lt;/p&gt;&lt;p&gt;&lt;code&gt;&lt;br&gt;ssh user@remotemachine "cd /path;tar -cf - target | gzip -c" &amp;gt; /path/target.tgz&lt;br&gt;&lt;/code&gt;&lt;/p&gt;&lt;p&gt;You've just had the remote machine produce a tarball, run it through gzip,  and dump the results to stdout.  You just captured that at your own workstation, and saved the results.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">bofh468</dc:creator><pubDate>Thu, 13 Nov 2003 16:02:20 -0000</pubDate></item></channel></rss>