Skip to content

Instantly share code, notes, and snippets.

@mullikine
Forked from mieky/ununzip.sh
Created May 25, 2020 04:02
Show Gist options
  • Save mullikine/e65c798bc94722ec2ade455cd5236e5d to your computer and use it in GitHub Desktop.
Save mullikine/e65c798bc94722ec2ade455cd5236e5d 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