kapott

cram.sh

Jan 2nd, 2019
380
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.42 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. if ! [ -x "$(command -v pigz)" ]; then
  4.     echo >&2 "I require pigz but it's not installed.  Aborting."
  5.     exit 1
  6. fi
  7.  
  8. if [ "$#" -eq "2" ]; then
  9.     dt=$(date --iso-8601)
  10.     threads=$(nproc --all)
  11.     filename="${1}_${dt}.tar.gz"
  12.     echo "[$0] Compressing ${@:2} into ${filename}"
  13.     tar cf - ${@:2} | pigz -9 -p "${threads}" > "${filename}"
  14. else
  15.     echo "[$0] Usage: $0 compressed_file_name files_or_dir_to_be_compressed"
  16. fi
Advertisement
Add Comment
Please, Sign In to add comment