Unzip All | Files In Subfolders Linux
But be careful – there is no “trash” recovery. Test first.
find . -name "*.zip" -exec sh -c 'unzip -o "$1" && rm "$1"' _ {} \;
To clean up after a successful extraction, append && rm but be careful: only delete if extraction succeeded. unzip all files in subfolders linux
If you have enabled globstar in bash, you can avoid find :
Check your current working directory before running any command – many of these examples operate relative to the current location. But be careful – there is no “trash” recovery
: find . -name "*.tar.gz" -exec tar -xzvf {} \; Quick Tips
Use the null-separated versions ( -print0 + read -d '' or xargs -0 ). -name "*
If you want to extract all files from all zip files into one flat directory (beware of filename collisions), use:
Run without arguments (current directory): ./unzip-all.sh With overwrite: ./unzip-all.sh . --overwrite With delete after extraction: ./unzip-all.sh . --delete
find . -type f -name "*.zip" -exec sh -c 'unzip -d "$(dirname "{}")" "{}" && rm "{}"' \;