How do I recursively unzip nested ZIP files?

后端 未结 4 516
无人共我
无人共我 2021-01-06 00:45

Given there is a secret file deep inside a nested ZIP file, i.e. a zip file inside a zip file inside a zip file, etc...

The zip files are named 1.zip, <

4条回答
  •  既然无缘
    2021-01-06 01:13

    Probably not the cleanest way, but that should do the trick:

    #!/bin/sh
    IDX=1 # ID of your first zip file
    while [ 42 ]
    do
        unzip $IDX.zip # Extract
        if [[ $? != 0 ]]
        then
            break # Quit if unzip failed (no more files)
        fi
        if [ $IDX -ne 1 ]
        then
            rm $IDX.zip # Remove zip to leave your directory clean
        fi
        (( IDX ++ )) # Next file
    done
    

提交回复
热议问题