tar bz2 a directory — a .bashrc function 
To make compression of directories into .tar.bz2 archives quick and simple, put the following function in your .bashrc file:
tar_bz2_dir()
{
if [ "$1" != "" ]; then
FOLDER_IN=`echo $1 |sed -e 's/\/$//'`;
FILE_OUT="$FOLDER_IN.tar.bz2";
FOLDER_IN="$FOLDER_IN/";
echo "Compressing $FOLDER_IN into $FILE_OUT…";
echo "tar cjf $FILE_OUT $FOLDER_IN";
tar cjf "$FILE_OUT" "$FOLDER_IN";
echo "Done.";
fi
}
Then, to compress directory dir/ into dir.tar.bz2 archive type:
tar_bz2_dir dir/
The following will be displayed:
$ tar_bz2_dir dir/ Compressing dir/ into dir.tar.bz2... tar cjf dir.tar.bz2 dir/ Done.
Did you find the above information useful and interesting? If so, please support this site by using the blog directory links at the bottom of this page. Thanks for your support!
If you have any Linux related problems or questions then please feel free to post them on our Linux Forums: http://linux.dsplabs.com.au/forums.

March 14th, 2011 at 2:29 am
Thanks. I looking them