Created
June 7, 2010 20:01
-
-
Save brinchj/429103 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/zsh | |
# Unpack in unique folder | |
dir=${1}_`uuid`; | |
mkdir ${dir}; | |
tar vxf $1 -C ${dir}; | |
# Move to working dir if only one folder unpacked | |
output=${dir}; | |
if [ `find ${dir} -maxdepth 1|wc -l` -eq 2 ]; then | |
if [ `find ${dir} -maxdepth 1 -type d|wc -l` -eq 2 ]; then | |
_output=`find ${dir} -maxdepth 1`; | |
_output=`basename ${_output}`; | |
if [ -d ${_output} ]; then; else | |
output=${_output}; | |
mv ${dir}/${output} .; | |
rmdir ${dir}; | |
fi | |
fi | |
fi | |
echo "$1 was unpacked in ./${output}."; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment