Skip to content
Permalink
Branch: master
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
38 lines (32 sloc) 745 Bytes
#!/bin/bash
print_help()
{
echo "Add current directory and subdirectories to tar.gz archive"
echo "Use "`basename $0`" [-nc]"
echo "[-nc] - add only content current directory (and subdirectories)."
echo
echo "Archive name == current directory name."
echo "Archive will be created to up-directory."
exit 1
}
if [[ "$1" == "-h" || "$1" == "--help" ]]; then
print_help
fi
CURDIR=`pwd`
if [ "$CURDIR" == "/" ]; then
echo "Oh, no! It's root directory!"
exit 1
fi
DIRNAME=`basename $CURDIR`
ARHNAME="../"$DIRNAME".tar.gz"
if [ $# -ne 1 ]; then
tar -czvf $ARHNAME "../"$DIRNAME
else
if [ "$1" == "-nc" ]; then
tar -czvf $ARHNAME "."
else
echo "Wrong parameter(s)!"
echo
print_help
fi
fi
You can’t perform that action at this time.