doZip.sh 294 B

123456789101112131415161718192021
  1. #!/bin/bash
  2. N=1;
  3. echo Narg $#;
  4. if [ $# -gt 0 ] ;
  5. then
  6. N=$1;
  7. echo Setting N to $N;
  8. fi;
  9. arr=($(echo */));
  10. echo Processing $N/${#arr[@]};
  11. for ((i=0;i<$N;i++)) ; do
  12. q=$(echo ${arr[i]} |sed 's/\///');
  13. zip -r $q.zip $q/*;
  14. rm -rf $q/*;
  15. rmdir $q;
  16. chown tomcat8:tomcat8 $q.zip;
  17. done;