How do you recursively unzip archives in a directory and its subdirectories from the Unix command-line?

前端 未结 10 653
旧巷少年郎
旧巷少年郎 2020-12-04 07:15

The unzip command doesn\'t have an option for recursively unzipping archives.

If I have the following directory structure and archives:

/Moth         


        
10条回答
  •  不知归路
    2020-12-04 07:17

    If you want to extract the files to the respective folder you can try this

    find . -name "*.zip" | while read filename; do unzip -o -d "`dirname "$filename"`" "$filename"; done;
    

    A multi-processed version for systems that can handle high I/O:

    find . -name "*.zip" | xargs -P 5 -I fileName sh -c 'unzip -o -d "$(dirname "fileName")/$(basename -s .zip "fileName")" "fileName"'
    

提交回复
热议问题