Map "untar" to tar xvfz?
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.
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.
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.
I'm always remembering it by saying it out loud:
tar e X tract Z ip F ile V erbose
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.
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.