Skip to content

Instantly share code, notes, and snippets.

@yangg
Created January 8, 2012 07:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yangg/1577569 to your computer and use it in GitHub Desktop.
Save yangg/1577569 to your computer and use it in GitHub Desktop.
tar
# zip
zip -r test.zip .vim .vimrc
unzip -l test.zip
zip -d test.zip filename_to_delete
zip -e test.zip path_to_file
zip -er test.zip path_to_folder
# rar
rar a test.rar .emacs.d .emacs
unrar x test.rar
# tar
# split tar to several files
tar cvjf - evernote-latest.exe | split -b 2m - evernote.tbz.
cat evernote.tbz.* | tar xvj
untar() {
if [ -f "$1" ] ; then
case $1 in
*.tar.bz2) tar xjf "$1" ;;
*.tar.gz) tar xzf "$1" ;;
*.tar.xz) tar xJf "$1" ;;
*.bz2) bunzip2 "$1" ;;
*.rar) rar x "$1" ;;
*.gz) gunzip "$1" ;;
*.tar) tar xf "$1" ;;
*.tbz2) tar xjf "$1" ;;
*.tgz) tar xzf "$1" ;;
*.zip) unzip "$1" ;;
*.7z) 7zr x "$1" ;;
*.Z) uncompress "$1" ;;
*.dmg) hdiutil mount "$1" ;;
*) echo "\`$1' cannot be extracted via untar" ;;
esac
else
echo "\`$1' is not a valid file"
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment