It's a nice web gadget. However, I just go by this handy table, which is on a yellow stickie on my monitor:
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" ;;
...
esac
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
}
Why not just learn what the flags mean? If you're cargo culting it, and not learning the point of the "xfvz" (it means eXtract, from the specified File, with a Visual dump of the extraction, from a gZipped archived tarball) -- you'll never remember it.
"tar xvzf" is already a part of my muscle memory. Occasionally I need to change the "z" to a "j" for bzip2 archives. And the "x" becomes a "c" if I'm Creating an archive rather than eXtracting.
Also this site doesn't show the command for files with ".tgz" extensions.
Yeps. I used to have to keep googling whenever I wanted to extract something. Then I decided to learn what the flags meant and realised how easy it was. When doing the command it was a matter of saying it in head ("I am extracting from this gzipped file"). Likewise for compressing. Only difference being 'c' stood for Compressing.
For GNU tar at least it's not necessary to specify the compression program when extracting--it will auto-detect it. Additionally when creating tar files it has -a, --auto-compress to use the file extension to determine the compression program to use.
I have good memory but I always try to convert information into mental cards so I can draw associations, that is how I have learned all commands you can imagine. I deactivated the system file manager of my operation system long time ago because I got used to the terminal, and that is how I do everything in my personal computer.
For 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
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.
That's the first thing I tried too. I thought the site was broken because there's no button to push and after hitting enter nothing happened. It's ok if you don't support everything yet, but at least have a message saying "Not yet implemented" or something, please.
Does not work if I don't use a dot at the beginning of the extension.
.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:
I've used this for years, not because I can't remember tar, gunzip, unzip, unrar, 7z, etc commands (although it takes a second to recall which flags to use for a particular archive format), but because it prevents tarbombs/zipbombs from filling my current working directory. It first extracts the archive to a temporary folder, and if it notices only one file in the folder, it moves it back one directory. One minor complaint is that "aunpack" is awkward to type, so I've aliased it to `a`.
Why hasn't anyone made (afaik) an all in one extractor that depends on all the popular compression tools and uses the appropriate one depending on the extension. That would be useful.
bsdtar does this, except by looking at the file format rather than looking at the extension. It supports tar, pax, cpio, zip, xar, lha, ar, cab, mtree, rar, and ISO images, compressed using gzip, bzip2, lzip, xz, lzma, or compress.
It's called tar. Seriously. I'm positive gnu tar will pick the compression engine based on the file contents, I think bsd does too. It's not a documented standard, but if all implementations support it, it may as well be.
Gee, I've been using a handrolled program that a) figures out what other program to delegate to as well as what options to pass and b) makes sure unpacking whatever results in exactly one new entry in the current directory, that is, unpacks into a newly created directory if there's more than one thing top-level in the archive. Maybe I should have been posting it on the internet!
Every time I need to extract some kind of tar file i just do tar -xf filename.tar.<whatever> and it works fine. This would be nice for compressing, but seems pointless.
[+] [-] kazinator|10 years ago|reply
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:
Hello, we have "case"[+] [-] quantumtremor|10 years ago|reply
[+] [-] ryenus|10 years ago|reply
[+] [-] indiv0|10 years ago|reply
[+] [-] snorrah|10 years ago|reply
[+] [-] gfodor|10 years ago|reply
[+] [-] reedlaw|10 years ago|reply
Also this site doesn't show the command for files with ".tgz" extensions.
[+] [-] nstart|10 years ago|reply
[+] [-] deciplex|10 years ago|reply
-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.
[+] [-] Hello71|10 years ago|reply
[+] [-] unknown|10 years ago|reply
[deleted]
[+] [-] Splognosticus|10 years ago|reply
http://www.gnu.org/software/tar/manual/html_node/gzip.html#a...
[+] [-] spartas|10 years ago|reply
[+] [-] guessmyname|10 years ago|reply
For 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:
https://github.com/xvoland/Extract[+] [-] mahouse|10 years ago|reply
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
[+] [-] scintill76|10 years ago|reply
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.
[1] https://xkcd.com/1168/
[+] [-] redwards510|10 years ago|reply
[+] [-] jamiesonbecker|10 years ago|reply
[+] [-] archinal|10 years ago|reply
[+] [-] txutxu|10 years ago|reply
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:
[+] [-] madprops|10 years ago|reply
Maybe because you're expected to type the full filename, for example crash34_master.tar.gz
[+] [-] anthonyu|10 years ago|reply
[+] [-] robalfonso|10 years ago|reply
co workers have sent this to me multiple times
https://xkcd.com/1168/
it helps the characters name is also mine!
[+] [-] carlosf8|10 years ago|reply
[+] [-] vortico|10 years ago|reply
[+] [-] madprops|10 years ago|reply
[+] [-] cperciva|10 years ago|reply
[+] [-] adrusi|10 years ago|reply
[+] [-] tetron|10 years ago|reply
http://brettcsmith.org/2007/dtrx/
[+] [-] kw71|10 years ago|reply
[+] [-] ben0x539|10 years ago|reply
[+] [-] keithgabryelski|10 years ago|reply
-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.
[+] [-] nickgartmann|10 years ago|reply
and
tar dash Compress Zee Files (tar -czf)
Yes, the z does nothing when extracting. But it helps me remember.
[+] [-] crimsonalucard|10 years ago|reply
In all seriousness... why? This would be an awesome unix tool.
[+] [-] gue5t|10 years ago|reply
http://freecode.com/projects/dtrx
[+] [-] mpnordland|10 years ago|reply
[+] [-] mydpy|10 years ago|reply
[+] [-] retrogradeorbit|10 years ago|reply
[+] [-] jfb|10 years ago|reply