Map "untar" to tar xvfz?
Solution 1
alias untar='tar -xvzf'
Place in your .bashrc file to persist across logins/shell sessions, or in your /etc/bash.bashrc file to persist for logins from all users on your system.
Solution 2
You might also be interested in the following:
x(){
if [ -f $1 ] ; then
case $1 in
*.tar.bz2) tar xvjf $1 ;;
*.tar.gz) tar xvzf $1 ;;
*.bz2) bunzip2 $1 ;;
*.rar) unrar x $1 ;;
*.gz) gunzip $1 ;;
*.tar) tar xvf $1 ;;
*.tbz2) tar xvjf $1 ;;
*.tgz) tar xvzf $1 ;;
*.zip) unzip $1 ;;
*.Z) uncompress $1 ;;
*.7z) 7z x $1 ;;
*) echo "Unable to extract '$1'" ;;
esac
else
echo "'$1' is not a valid file"
fi
}
With the above code in your .bashrc, typing an x followed by a filename will extract most archives you come across (assuming you have the packages needed to extract that type of archive).
NOTE: This code is slightly modified from what I found here a long time ago.
Solution 3
I'm always remembering it by saying it out loud:
tar e X tract Z ip F ile V erbose
Solution 4
Does no one else use atool? It's a command-line tool for format-agnostic archiving and extraction.
To unpack any supported archive: aunpack archive.zip
To pack files into any supported archive: apack archive.tar.bz2 *.txt
To list files in any supported archive: als archive.tgz
I can't remember the last time I've directly used any archive-specific tool.
Solution 5
You should try dtrx
- it'll work out the correct arguments for many types of files, including "tar, zip, cpio, deb, rpm, gem, 7z, cab, rar, gz, bz2, lzma, xz, and many kinds of exe files, including Microsoft Cabinet archives, InstallShield archives, and self-extracting zip files." It also puts the contents into a single directory, regardless of whether the archive was packed like that or not.
Related videos on Youtube
meder omuraliev
Updated on September 17, 2022Comments
-
meder omuraliev over 1 year
How can I map 'untar' as a command to 'tar -xvfz' ? Sorry, but I almost always forget the arguments necessary to 'tar' for this operation.
-
Caotic over 14 yearsDepending on your Operating system you might want to leave out the -z parameter. At least on debian tar automatically detects the compression type and using -z on a tar file that is not compressed with gzip causes an error there
-
Richard Hoskins over 14 yearsAlso, the -z option is a GNU extension.
-
niXar over 14 years@Richard: subby tagged it Linux @ledbettj: z option is unnecessary on recent (<4 years, at least) gnu tar, it's handled automagically and it does croak if there is not gzipping or if it's bzipp'd instead. Also "-" is unnecessary and does print a warning on occasions.
-
meder omuraliev over 14 yearswow. that's awesome too.
-
Assaf Levy over 14 yearsFor me consciously remembering this isn't an issue because my left hand fingers "automatically" come up with "zxfv"... :)
-
Oskar Duveborn over 14 years@Jonik so true ^^
-
lprsd over 14 yearsNot even there in the Ubuntu repos. Not a great way for installation!
-
TRS-80 over 14 yearsIt was only added to Debian earlier this year, so it's only in karmic, but you should be able to install the .deb on jaunty with no problems.
-
Wolf over 14 years.rar has been included twice. I don't think the second version will ever be executed. Or will it?
-
Richie Marquez over 14 yearsMy apologies, the second *.rar line should not be there; it will never be executed.
-
killermist over 11 yearsWith the catchall at the end of the case block, will the else block ever trigger?