Skip to content

Instantly share code, notes, and snippets.

@mieky
Created May 9, 2013 10:25
Show Gist options
  • Save mieky/5546743 to your computer and use it in GitHub Desktop.
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.
#!/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