I have a zip file and in that I have multiple folders zipped. How do I unzip all the files in one shot.
I tried unzip -r but it didn't work
Regards, Vikas
Hack solution:
until [ "$(find . -name '*.zip' | wc -l)" = 0 ]; do ZIP="$(find . -name '*.zip' | head -1)"; cd $(dirname "$ZIP") && unzip $(basename "$ZIP") && cd - && mv "$ZIP" "$ZIP.bak"; done
The quoting isn't perfect, so it might not work if you have spaces or other special characters in your directories or zipfiles.
until find . -name '*.zip' | grep -q .; do
as a simpler (probably more efficient) check. Also, you should quote all the other command substitutions "$(dirname ...)"
, "$(basename ...)"
, etc.
– muru
Apr 19 '18 at 05:25
unzip
does not have a-r
option. – stumblebee Apr 19 '18 at 01:21