Zip script using bash

Viewed 55

I'm trying to write a line in my bash script that will take all the subdirectories that exist in the working directory that are older than 7 days and zip them up into one zip file, then delete those subdirectories.

Any guidance would be much appreciated!

1 Answers

You should rewrite you command as:

find $WORK_DIR \
  -type d \
  -mtime +7 \
  -exec bash -c "zip -q -m -j -J $WORK_DIR/$NEWZIP.zip {} && rm -rf {}" \;

Where {} is the file (directory) name placeholder.

Related