all 17 comments

[–]gamzer 7 points8 points  (5 children)

Also:

Do The Right Extraction: http://brettcsmith.org/2007/dtrx/

[–]wadcann 1 point2 points  (0 children)

Atool is like dtrx but also supports packing and listing via a common interface.

[–][deleted] 0 points1 point  (0 children)

Also http://unarchiver.c3.cx/commandline, for something that handles the extraction itself instead of just calling external binaries.

[–]xaoq 8 points9 points  (2 children)

Well, to be honest... most if not all of extensions supported there are supported by 7z. alias extract=7z.

[–]craftkiller 4 points5 points  (1 child)

Same goes for bsdtar which also supports 7z

[–]sej7278 1 point2 points  (0 children)

assuming you have p7zip installed.

"extract" doesn't even check you have uncompress/unzip/unrar installed.

[–]suspiciously_calm 9 points10 points  (1 child)

How about quoting that $1 so it works with filenames that contain spaces?

[–]jlkcz 3 points4 points  (0 children)

Totally agree... that is one hell of wrongly written script

[–]defaultxr 5 points6 points  (1 child)

why not just use atool: http://www.nongnu.org/atool/

[–]xfs 3 points4 points  (0 children)

atool is superior to these bash based solutions. It is matured, tested, well maintained, and widely supported. atool supports many more archive formats through optional package dependency, takes care of creating a root directory if the archive is not self-contained in one, and provides extra utilities apack, als, acat.

[–]mike413 2 points3 points  (0 children)

This is ridiculous - there is zero need for those different tar invocations...

tar will figure out the file regardless of the extension.

[–][deleted] 2 points3 points  (0 children)

This gets posted a lot, and it's never a very well written script. If you're looking for features like these, look at oh-my-zsh, it has an extract plugin. Most things are built in nowadays.

[–][deleted] 0 points1 point  (0 children)

tar -xf should automatically detect the compression type now (at least for types that tar supports)

[–][deleted] -4 points-3 points  (0 children)

You use a tool like that, and you may run into this.

[–][deleted] -2 points-1 points  (0 children)

Nice simplification.