dir2tgz 403 B

1234567891011121314151617181920212223
  1. #!/bin/sh
  2. if [ ! $1 ];then
  3. echo 'Usage: # dir2tgz <name of directory>'
  4. exit 1
  5. fi
  6. DIRNAME="`echo -n $1 | sed -e 's%/$%%'`"
  7. DIRNAME="`basename $DIRNAME`"
  8. if [ ! -d $DIRNAME ];then
  9. echo "Error: $DIRNAME not found. Must open terminal in same directory."
  10. exit 1
  11. fi
  12. echo "Converting directory $DIRNAME to $DIRNAME.tar.gz..."
  13. tar -c -f ${DIRNAME}.tar ${DIRNAME}/
  14. gzip ${DIRNAME}.tar
  15. sync
  16. echo "Done"