LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   bash script: skip files bigger than xGB (https://www.linuxquestions.org/questions/linux-newbie-8/bash-script-skip-files-bigger-than-xgb-765530/)

laurens 10-30-2009 05:31 AM

bash script: skip files bigger than xGB
 
Hello all,

I have this basic script to backup files to a NAS:

Code:

#!/bin/bash

#home mappen zippen
cd /ananas/BACKUP/IMMSERV1
zip -r $(date +%m%d%Y)-ImpactAdmin.zip /folder1/
zip -r $(date +%m%d%Y)-ImpactStore.zip /folder2/
zip -r $(date +%m%d%Y)-homes.zip /home/

#verwijder alle bestanden ouder dan 3 dagen op de sienas
find /ananas/BACKUP/IMMSERV1 -type f -mtime +2 -exec rm {} \;

#sluiten
exit

but now I would like the zip command to skip files bigger than e.g. 10GB. Is this possible with piping? Thanks in advance!

acid_kewpie 10-30-2009 06:54 AM

from "man zip"
Quote:

If the file list is specified as -@, [Not on MacOS] zip takes the list of input files from standard input. Under UNIX, this option can be used to powerful effect in conjunction with the find(1) command. For example, to archive all the C source files in the current directory and its subdirectories:
find . -name "*.[ch]" -print | zip source -@
so here you can just turn it around to be
Code:

find . -size -10G -print | zip myzipfile -@

laurens 10-30-2009 07:34 AM

Quote:

Originally Posted by acid_kewpie (Post 3737824)
from "man zip"

so here you can just turn it around to be
Code:

find . -size -10G -print | zip myzipfile -@

Thanks. Only, what would be the exact command in my case ? Thx. It should still be one file but just with the +10GB files skipped

acid_kewpie 10-30-2009 12:23 PM

erm.. i just gave you it... :confused: If you don't understand what a command you are given does, clearly you should never really run it. Maybe I'm tricking you..? Read the zip manpage as I quoted and check out what the command is actually doing if you can't tell from reading it directly.


All times are GMT -5. The time now is 06:50 PM.