Also this site doesn't show the command for files with ".tgz" extensions.
With modern tar, just don't include the z at all. "tar -xf" knows how to extract various kinds of compressed tar files automatically.
-cf Create File -xf eXtract File
then you have the adverb v, and the adjective z:
-vczf Verbosely Create gZip File -vxzf Verbosely eXtract gZip File
I find it difficult to remember the arguments mostly because I seldom use tar, not because the arguments are unintuitive or something.
extract ()
{
if [ -f $1 ] ; then
case $1 in
*.tar.bz2) tar xjf $1 ;;
*.tar.gz) tar xzf $1 ;;
*.bz2) bunzip2 $1 ;;
*.rar) unrar x $1 ;;
*.gz) gunzip $1 ;;
*.tar) tar xf $1 ;;
*.tbz2) tar xjf $1 ;;
*.tgz) tar xzf $1 ;;
*.zip) unzip $1 ;;
*.Z) uncompress $1;;
*.7z) 7z x $1 ;;
*) echo "'$1' cannot be extracted via ex()" ;;
esac
else
echo "'$1' is not a valid file"
fi
}It looks like it does not recognise other usual things such as .gz alone or .tgz: https://github.com/Mawalu/extract-it/blob/gh-pages/main.js
var input = document.querySelector('#leInput'),
commands = {
'.tar': 'tar xfv',
'.zip': 'unzip',
'.tar.bz2': 'tar jxvf',
'.tar.gz': 'tar xfvz',
'.tar.bz': 'tar xjf',
};
I don't think the difference between .bz2 and .bz makes any sense. Am I wrong, or is it just that bz2 extracts verbosely and bz doesn't? I'd guess these flags were copied from some random sources without the author realizing they are nearly equivalent.I know difficulty with tar is a meme[1], but once you get over that "j" means bz2, why is it hard to remember V for Verbose, Z for gZip, X for eXtract, F for File (which you'll almost always be passing)? I ask this both rhetorically because it shouldn't be hard, but also because I am sometimes oddly hesitant when forming tar commands. But not enough to reach for a web page.
http://www.gnu.org/software/tar/manual/html_node/gzip.html#a...
alias untar="tar xvf"
Then, open a new terminal window, and from then on it's just: untar filename.tar.gzIn all seriousness... why? This would be an awesome unix tool.
.tar -> enter -> works
tar -> enter -> nothing happens
I use an extract() function on my shell initialization files. It deals with most formats for me.Anyway nice to see it implemented on a web interface, the source code is really brief :-)
Right now it supports tar, tar.gz, tar.bz, tar.bz2 and zip. If you want to deal with more formats, you have plenty of places to look for the 'ext => cmd' relation:
https://github.com/search?q=extractMaybe because you're expected to type the full filename, for example crash34_master.tar.gz
NAME MODERN GNU TAR COMMAND
file.tar.gz tar xf file.tar.gz
file.tar.bz tar xf file.tar.bz
file.tar.bz2 tar xf file.tar.bz2
file.tar tar xf file.tar
file.tgz tar xf file.tgz (missing from web gadget!)
file.abcdef tar xv file.abcdf (*)
---
* If file.abcdf is actually any of the preceding formats;
i.e. GNU Tar doesn't just go by the suffix!
Nobody memorizes these, and I wouldn't want to turn into a nobody, right?By the way, if you actually do need a command which performs a pattern match on a file name and dispatches some other command, why would you go through a web browser? You'd want this in your shell as a function:
$ dtrt x.blorch.zonk.bloop # "do the right thing"
Hello, we have "case" case "$file" in
-* | --* ) echo "oops, $file looks like an option!" ;;
*.zip ) unzip "$file" ;;
*.rar ) ... ;;
*.tar.* | *.tgz | *.tar ) tar xf "$file" ;;
...
esacFor extraction of archives I am able to remember the commands like this. For files with "tar" extension I use "tar xf" (where "x" means eXtract and "f" file, I think so). Now, if the extension is "tar.bz2" add a "j", and "z" for "tar.gz". For "zip" files use "unzip" and start adding a prefix like "b" or "g" for "bz2" and "gz" files respectively:
file.tar -> tar xf
file.tar.gz -> tar xfz
file.tar.bz2 -> tar xfj
file.zip -> unzip
file.bz2 -> bunzip2
file.gz -> gunzip
https://github.com/xvoland/Extractco workers have sent this to me multiple times
it helps the characters name is also mine!
-x EXTRACT -c CREATE -f - USE STDIN/OUT
to create a tar file of the current directory:
tar -cf - . | gzip > /tmp/foo.tar.gz
to extract:
gzip < /tmp/foo.tar.gz | tar -xf -
why tar has all the options was someone's idea they were helping you out -- they weren't
Create is -c --- remember that eXtract is -x - remember that -f - is stdout/stdin depending on your need -- remember that
pipes are your friend.
and
tar dash Compress Zee Files (tar -czf)
Yes, the z does nothing when extracting. But it helps me remember.