Created
May 9, 2013 10:25
-
-
Save mieky/5546743 to your computer and use it in GitHub Desktop.
Un-unzip a file without a root folder that spews its contents all around the place.
This file contains 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/bash | |
# A bash-wrapped version of http://www.commandlinefu.com/commands/view/9536/un-unzip-a-file | |
if [ $# -eq 0 ]; then | |
echo "Un-unzips a file without a root folder." | |
echo "Usage: ununzip <filename>" | |
exit 1 | |
elif [ ! -e $1 ]; then | |
echo "File not found: $1" | |
exit 1 | |
fi | |
unzip -l $1 | awk '{ if($4 != "Name" && $4 != "----") print $4}' | xargs -t rm -rf {} &> /dev/null |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment