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

前端 未结 10 648
旧巷少年郎
旧巷少年郎 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:32

    This works perfectly as we want:

    Unzip files:

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

    Above command does not create duplicate directories.

    Remove all zip files:

    find . -depth -name '*.zip' -exec rm {} \;
    

提交回复
热议问题