I have hundreds of multiple folders which contains thousands of zip files which contain nested within the zip files like show on three below
start tree structure
012016/
├── 2016-01
│ └── 2016-01
│ ├── build
│ ├── DOC
│ │ ├── WONWA1
│ │ │ ├── WO1NWA1
│ │ │ │ ├── WO2016000001NWA1.xml
│ │ │ ├── WO1NWA1.zip
│ │ │ ├── WO2NWA1
│ │ │ │ ├── WO2016000002NWA1_tr.xml
│ │ │ ├── WO2NWA1.zip
└── 2016-01.zip
end tree structure
I have created a short script below which check for the folder and contents recursively, and if it finds any zip files it extracts the contents and then continues to check the contents of the extracted folder.
When I try to run the script below:
recurse() {
for i in "$1"/*;
do
currentItem="$i"
extension="${currentItem##*.}"
if [ -d "$i" ]; then
#echo "dir: $i"
recurse "$i"
elif [ -f "$i" ]; then
#echo "file: $i"
#echo "ext: $extension"
[[ ${extension} = +(sh|xslt|dtd|log|txt) ]] && break
extractionDirectory=$(dirname $currentItem)/$(basename -s .zip $currentItem )
[[ ${extension} = "zip" ]] && unzip -uq $currentItem -d "${extractionDirectory}"
recurse ${extractionDirectory}
fi
done }
recurse $PWD
However, when i run the above script I am getting the error:
Segmentation fault (core dumped)
-x
option, as inbash -x /path/to/myscript.sh
or before any processing occurs in your script, insert the lineset -x
. The verbose output can show you the core dumping executable. – MelBurslan Jul 18 '16 at 15:25