LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-30-2009, 05:31 AM   #1
laurens
Member
 
Registered: Mar 2009
Posts: 65

Rep: Reputation: 15
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!
 
Old 10-30-2009, 06:54 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984
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 -@
 
Old 10-30-2009, 07:34 AM   #3
laurens
Member
 
Registered: Mar 2009
Posts: 65

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by acid_kewpie View Post
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
 
Old 10-30-2009, 12:23 PM   #4
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984
erm.. i just gave you it... 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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Bash script to convert .mpg files to .avi files? Mike_Snyder Linux - Newbie 5 09-19-2009 01:33 PM
Trouble with making a bash script to read in different files and rename output files. rystke Linux - Software 1 05-07-2009 08:00 AM
To rename files in a directory should I use Bash script or a Perl Script ? jamtech Programming 7 01-22-2008 11:25 PM
Command to copy files/folders but skip bad/corrupt files?? leemoreau Linux - Newbie 2 04-02-2007 02:27 PM
bash script - If file is bigger than 50 meg then ... paul_mat Linux - Software 3 06-20-2006 02:26 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:03 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration