#!/bin/bash N=1; echo Narg $#; if [ $# -gt 0 ] ; then N=$1; echo Setting N to $N; fi; arr=($(echo */)); echo Processing $N/${#arr[@]}; for ((i=0;i<$N;i++)) ; do q=$(echo ${arr[i]} |sed 's/\///'); zip -r $q.zip $q/*; rm -rf $q/*; rmdir $q; chown tomcat8:tomcat8 $q.zip; done;