#!/usr/bin/env sh ###################################################################### # @author : Garhve (garhve@gmail.com) # @file : decrypt # @created : Wednesday Jan 10, 2024 01:09:07 CST # # @description : decrypt files that encrypt by gpg ###################################################################### for file in $@ do # get suffix suffix=$(echo "$file" | rev | cut -d '.' -f1 | rev) # get no suffix name f_no_suffix="${file%.*}" # check either name is ending with gpg or a* if [ $suffix = "gpg" ]; then # if end with gpg, decrypt directly gpg --output "${f_no_suffix}" --decrypt "$file" tar zxvf "${f_no_suffix}" && rm $f_no_suffix else # else join the parts before decrypt cat ${f_no_suffix}.* > "$f_no_suffix" # get name without gpg suffix f_no_gpg="${f_no_suffix%.*}" gpg --output "${f_no_gpg}" --decrypt "$f_no_suffix" tar zxvf "$f_no_gpg" && rm $f_no_gpg $f_no_suffix fi done