Skip to content

Instantly share code, notes, and snippets.

@rietta
Created October 2, 2013 04:29
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 rietta/6789165 to your computer and use it in GitHub Desktop.
Save rietta/6789165 to your computer and use it in GitHub Desktop.
Tarbar a directory and move the original to the Trash. First, install these from Hamebrew: brew install trash brew install pigz
#!/usr/bin/env bash
# Archive a directory into a compressed tar file
# and prepare a text file that lists all of the files in each archive.
###
# The trash command is OS X specific ane requires a 3rd party tool -
# brew install trash
# brew install pigz
###
if [ -d "$1" ]; then
echo "Compressing and preparing a file listing $1..."
#tar -jcf "${1%/}.tar.bz2" "$1" && tar -jtvf "${1%/}.tar.bz2" > "${1%/}.tar.txt" && trash "$1"
tar --use-compress-program=pbzip2 -cf "${1%/}.tar.bz2" "$1" && tar -jtvf "${1%/}.tar.bz2" > "${1%/}.tar.txt" && trash "$1"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment