Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 10-26-2004, 04:56 AM   #1
LQ Newbie
Registered: Oct 2004
Posts: 1

Rep: Reputation: 0
Script for gzipping all files that's older than one year

Hi, i'm trying to make a bash script that will compress (gzip) all files in a folder (home folder in this case) that is older than one year (unused files, that is). Unfourtunately I'm still very much of a newbie, and would appreciate any suggestions.

Thanks in advance!

Last edited by Pengu010011; 10-26-2004 at 07:12 AM.
Old 10-26-2004, 07:47 AM   #2
LQ 5k Club
Registered: May 2003
Location: London, UK
Distribution: Debian "Testing"
Posts: 6,096

Rep: Reputation: 408Reputation: 408Reputation: 408Reputation: 408Reputation: 408
man find will tell you how to find the files that are untouched for over a year (hint, 1year = 365 days, usually).
Old 10-26-2004, 07:53 AM   #3
Registered: Dec 2003
Location: Little Rock, AR
Distribution: Fedora Core 2, AIX, HP-UX, Solaris, Whitebox
Posts: 193

Rep: Reputation: 31
Part of what you need is going to be is the find command, which should be able to do exactly what you want.

Something like

find $SEARCHPATH -mtime +365 -exec \ gzip {} \;
Someone else might come up with a more elaborate way to do this, but that should work for you.


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
Older 2.4.8 based system ok for a year, now problems rylan76 Linux - Software 0 10-21-2005 04:20 PM
Mandrake and compressing files stevsom Linux - Software 1 06-06-2005 07:52 PM
compressing files master Linux - Newbie 4 03-18-2004 11:48 AM
zipping/compressing folders and files DiZASTiX Linux - Newbie 1 05-26-2003 08:48 PM
Compressing files GtkUser Linux - Software 1 04-02-2003 06:21 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:51 AM.

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