LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
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 06-09-2008, 10:02 AM   #1
nixusr
LQ Newbie
 
Registered: Aug 2007
Posts: 3

Rep: Reputation: 0
Zipping files by a date range


My co-worker asked me a great question and I know the answer is yes but I do not know how to execute it.

He asked if it is possible to 'zip' files by date range. He needed to zip up a huge number of 'html' files but only wanted to zip up ones from lets say 2003-2008.

Not sure if 'xargs' and 'sort' would need to be used or even how to pipe them along.

Any ideas?
 
Old 06-09-2008, 03:43 PM   #2
MasterC
LQ Guru
 
Registered: Mar 2002
Location: Salt Lake City, UT - USA
Distribution: Gentoo ; LFS ; Kubuntu ; CentOS ; Raspbian
Posts: 12,613

Rep: Reputation: 69
I'd probably using the 'find' command. There are a couple of options, but I'd probably work on using the mtime option. You can then either pipe that into your tar arguments, or call using the -exec option as part of find. I'd probably pipe it into tar personally.

Good luck!

-Chad
 
Old 06-09-2008, 04:05 PM   #3
alan_ri
Senior Member
 
Registered: Dec 2007
Location: Croatia
Distribution: Debian GNU/Linux
Posts: 1,733
Blog Entries: 5

Rep: Reputation: 127Reputation: 127
Code:
 zip -rt 12071991 infamy foo
will add all the files in foo and its subdirectories that were last modified
on or after 7 December 1991, to the zip archive infamy.zip.
Code:
 zip -rtt 11301995 infamy foo
will add all the files in foo and its subdirectories that were last modified

before the 30 November 1995, to the zip archive infamy.zip.
 
Old 06-10-2008, 12:14 PM   #4
nixusr
LQ Newbie
 
Registered: Aug 2007
Posts: 3

Original Poster
Rep: Reputation: 0
Awesome, thanks! I will give this a shot. This seems very straight forward to use.


Quote:
Originally Posted by alan_ri View Post
Code:
 zip -rt 12071991 infamy foo
will add all the files in foo and its subdirectories that were last modified
on or after 7 December 1991, to the zip archive infamy.zip.
Code:
 zip -rtt 11301995 infamy foo
will add all the files in foo and its subdirectories that were last modified

before the 30 November 1995, to the zip archive infamy.zip.
 
  


Reply



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
deleting by date a specific range of files nooks12 Linux - Newbie 2 01-08-2008 02:45 PM
tar a date range rayia Programming 3 01-03-2006 07:52 AM
Zipping of files rajesh_b Programming 5 10-27-2004 06:02 AM
zipping files with a script quickk Linux - Newbie 8 09-17-2004 09:32 AM
zipping/compressing folders and files DiZASTiX Linux - Newbie 1 05-26-2003 08:48 PM

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

All times are GMT -5. The time now is 07:53 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