Skip to content

Instantly share code, notes, and snippets.

@Fawers
Created December 13, 2021 18:21
Show Gist options
  • Save Fawers/6752a4ff97af1d3373e2423aace8fe93 to your computer and use it in GitHub Desktop.
Save Fawers/6752a4ff97af1d3373e2423aace8fe93 to your computer and use it in GitHub Desktop.
Untar ARCHIVE into DIR
function untar_into() {
[[ -z "$1" ]] && echo "No tar file specified" && return
[[ -z "$2" ]] && echo "No destination specified" && return
[[ ! -e "$1" ]] && echo "Specified tar file absent: $1" && return
[[ -e "$2" ]] && echo "Destination dir already exists: $2" && return
local archive=$1
local target=$2
mkdir -pv $target
mv $archive $target
cd $target
tar -xvf $archive
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment