snipt

Ctrl+h for KB shortcuts

Bash

Tar ball tar.gz compress quick

#!/bin/bash
tar -cvzf $1.tar.gz $1
https://snipt.net/embed/55ef009ae34e3468eecef57053db1179/
https://snipt.net/raw/55ef009ae34e3468eecef57053db1179/
55ef009ae34e3468eecef57053db1179
bash
Bash
2
2016-09-21T13:35:50
True
False
False
/api/public/snipt/95069/
tar-ball-targz-compress-quick
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a><span class="c">#!/bin/bash</span> </span><span id="L-2"><a name="L-2"></a>tar -cvzf <span class="nv">$1</span>.tar.gz <span class="nv">$1</span> </span></pre></div> </td></tr></table>
compress, gz, tar, zip

Bash

TAR command to preserve files' permissions

1
2
3
4
5
# Compression
tar -pcvzf ABC.tar.gz ABC

# Decompression
tar -pxvzf ABC.tar.gz
https://snipt.net/embed/4d97bbd42854bf8c9bcb8d0c3b31e472/
https://snipt.net/raw/4d97bbd42854bf8c9bcb8d0c3b31e472/
4d97bbd42854bf8c9bcb8d0c3b31e472
bash
Bash
5
2016-09-29T14:43:18
True
False
False
Oct 18, 2013 at 03:10 AM
/api/public/snipt/87757/
tar-command-to-preserve-files-permissions
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a> <a href="#L-4">4</a> <a href="#L-5">5</a></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a><span class="c"># Compression</span> </span><span id="L-2"><a name="L-2"></a>tar -pcvzf ABC.tar.gz ABC </span><span id="L-3"><a name="L-3"></a> </span><span id="L-4"><a name="L-4"></a><span class="c"># Decompression</span> </span><span id="L-5"><a name="L-5"></a>tar -pxvzf ABC.tar.gz </span></pre></div> </td></tr></table>
bash, gz, permissions, tar

Bash

extract a specific file from a tar.gz

$ tar xfz abc.tar --wildcards --no-anchored 'redpics*'
https://snipt.net/embed/ab0da6899101a03376177ec62f65a74b/
https://snipt.net/raw/ab0da6899101a03376177ec62f65a74b/
ab0da6899101a03376177ec62f65a74b
bash
Bash
1
2016-09-28T17:42:38
True
False
False
Feb 23, 2013 at 07:10 PM
/api/public/snipt/53824/
extract-a-specific-file-from-a-targz
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a><span class="nv">$ </span>tar xfz abc.tar --wildcards --no-anchored <span class="s1">&#39;redpics*&#39;</span> </span></pre></div> </td></tr></table>
extract, find, gz, tar, zip

Bash

Extracting an Entire tar.gz Archive

tar -xvf [filename].tar.gz
https://snipt.net/embed/513f65aa5c3f3e3f7782b6859d26eecc/
https://snipt.net/raw/513f65aa5c3f3e3f7782b6859d26eecc/
513f65aa5c3f3e3f7782b6859d26eecc
bash
Bash
1
2016-09-29T18:01:28
True
False
False
/api/public/snipt/36516/
extracting-an-entire-targz-archive
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a>tar -xvf <span class="o">[</span>filename<span class="o">]</span>.tar.gz </span></pre></div> </td></tr></table>
archive, extract, gz, tar

Bash

Compress an entire folder

tar -cvf [filename].tar.gz [folder path]
https://snipt.net/embed/fcdf41273abb586a4ab641097ebf3798/
https://snipt.net/raw/fcdf41273abb586a4ab641097ebf3798/
fcdf41273abb586a4ab641097ebf3798
bash
Bash
1
2016-09-28T15:21:40
True
False
False
/api/public/snipt/35963/
compress-an-entire-folder
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a>tar -cvf <span class="o">[</span>filename<span class="o">]</span>.tar.gz <span class="o">[</span>folder path<span class="o">]</span> </span></pre></div> </td></tr></table>
compress, folder, gz, linux, tar, zip

Text only

Create a tar.gz file

tar -cvzf <output-file.tar.gz> <input-file-1> <input-file-2> ...
https://snipt.net/embed/68ad06a5288d190a1688965adda46a71/
https://snipt.net/raw/68ad06a5288d190a1688965adda46a71/
68ad06a5288d190a1688965adda46a71
text
Text only
2
2016-09-28T10:07:36
True
False
False
/api/public/snipt/22178/
create-a-targz-file-2
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a>tar -cvzf &lt;output-file.tar.gz&gt; &lt;input-file-1&gt; &lt;input-file-2&gt; ... </span></pre></div> </td></tr></table>
gz, tar

Text only

untar tar.gz

//I always forget! 
tar -zxvf filename.tar.gz 
https://snipt.net/embed/5c01ab6d43bd4d4529fd1031f28adafc/
https://snipt.net/raw/5c01ab6d43bd4d4529fd1031f28adafc/
5c01ab6d43bd4d4529fd1031f28adafc
text
Text only
2
2016-09-28T06:30:14
True
False
False
/api/public/snipt/15228/
untar-targz
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a>//I always forget! </span><span id="L-2"><a name="L-2"></a>tar -zxvf filename.tar.gz </span></pre></div> </td></tr></table>
gz, gzip, tar, tarball
Copyrighted, illegal, or inappropriate content? Email support@snipt.net.