Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/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
Add Comment
Please, Sign In to add comment