Advertisement
ghiwar

Zip Archive With Limited Number of Files

May 23rd, 2019
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.44 KB | None | 0 0
  1. find . ! -name "*.zip" -type f -print0 | parallel -0 -N 5 zip arch{#} {}
  2.  
  3. The option -N 5 limits the number of files to 5 per archive and is presented to zip in place of {}
  4.  
  5. The {#} (verbatim, not to be replaced by you during the invocation), is replaced by the job number, resulting in arch1.zip, arch2.zip etc.
  6.  
  7. The -print0 option to find and -0 option to parallel in tandem make sure that filenames with special characters are correctly handled.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement