Skip to content

Instantly share code, notes, and snippets.

@Jan-Zeiseweis
Created September 14, 2015 17:17
Show Gist options
  • Save Jan-Zeiseweis/dd9fd9fe5716d73e9b95 to your computer and use it in GitHub Desktop.
Save Jan-Zeiseweis/dd9fd9fe5716d73e9b95 to your computer and use it in GitHub Desktop.
Unzip all zip files in a directory and remove unzipped file if a file with the same md5checksum already unzipped
#!/bin/bash
declare -A arr
for zip_file in *.zip; do
unzip -q $zip_file && rm $zip_file
file=${zip_file%.zip}
read cksm _ < <(md5sum "$file")
if ((arr[$cksm]++)); then
echo "rm $file"
rm $file
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment