0

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

1 Answers1

1

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.

habs
  • 245
  • 1
    You can use 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