Skip to content

Instantly share code, notes, and snippets.

@warmwaffles
Created October 22, 2017 20:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save warmwaffles/e8544c4e25d67c21ec16a9533045ee5b to your computer and use it in GitHub Desktop.
Save warmwaffles/e8544c4e25d67c21ec16a9533045ee5b to your computer and use it in GitHub Desktop.
#!/bin/bash
# Usage: unpack <pathto file> <workdir>
set -e
archive=$1
workdir=$2
filename=$(basename "$1")
# echo "archive: $archive"
# echo "workdir: $workdir"
# echo "filename: $filename"
pushd "$workdir" > /dev/null
7z x -bd -y "$filename" > /dev/null
count=$(ls -1 *.iso 2>/dev/null | wc -l)
if [ $count != 0 ]
then
7z x -bd -y *.iso > /dev/null
rm -f *.iso
fi
# Leave workdir
popd > /dev/null
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment