tar-archive.sh 277 B

1234567891011121314
  1. #!/usr/bin/env bash
  2. set -euo pipefail # bash strict mode
  3. display_help(){
  4. echo "Usage: ${0##*/} [gzip,xz,bzip2] [file/s]"
  5. exit 2
  6. }
  7. [[ $# -lt 2 ]] && display_help
  8. cmd="$1"
  9. archive="${2}_$(date '+%Y-%m-%d-%H%M%S').tar.${cmd}"
  10. tar -cvf - ${@:2} | "$cmd" -9 > "$archive"