If you have a few zip files in a folder, and the zip file had compressed some child zips, the following shell script can help you to extract them.

The compressed information in our example look like:



Shell script:

#! /usr/bin/bash

# find zips in current path
files=()
find . -maxdepth 1 -name "*.zip" -print0 >tmpfile
while IFS=  read -r -d $'\0'; do
    files+=("$REPLY")
done < tmpfile

len=${#files[*]}
folders=()
for(( i=0;i<${len};i++ )); do
    zipName="${files[$i]}"
    masterName=${zipName%.*}
    unzip -o ${files[$i]} -d $masterName > tmpfile
    folderName=$(cat tmpfile | grep -m1 'creating:' | cut -d' ' -f5)
    if [ -z "$folderName" ]; then
        folderName="${masterName}"
    fi
    echo $folderName
    folders+=("$folderName")
done

len=${#folders[*]}
for(( i=0;i<${len};i++ ));do
    subZips=()
    find ${folders[$i]} -maxdepth 1 -name "*.zip" -print0 > tmpfile
    while IFS=  read -r -d $'\0'; do
        subZips+=("$REPLY")
    done < tmpfile

    zipLen=${#subZips[*]}
    for(( j=0;j<${zipLen};j++ )); do
        unzip -o ${subZips[$j]} -d ${folders[$i]}
    done
done

The result looks like the following image.


0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments

Tex To PDF
: convert the Latex file which suffix is tex to a PDF file

X
0
Would love your thoughts, please comment.x
()
x