LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 04-25-2011, 07:22 PM   #1
Arun Gupta
LQ Newbie
 
Registered: Apr 2011
Posts: 3

Rep: Reputation: 0
Linux zip program's -d -tt option deletes all files from zip archive


I have recently started working with Linux server (Oracle Enterprise Linux 5.5 which is same as Red Hat Linux 5.5). I have worked on Linux but not extensively. Whenever I run into a problem, Google search always finds me more that one right answers on this forum. Today I decided to register and post a question to which I could not find any answer.

Here is my problem.

I am using Linux zip utility to zip the logs into a zipped archive, say logs.zip. To delete logs older than 30 days from the zip file, I wanted to use the -d -tt options but these are not working as I expected.

My understanding of -d and -tt option is that -d will delete files from archive and -tt mmddyyyy will delete only files older than a certain date. However, when I use the -d -tt mmddyyyy options, all files are deleted from the archive irrespective of the file modification date.


-d
Remove (delete) entries from a zip archive.

-tt mmddyyyy
Do not operate on files modified after or at the specified date, where mm is the month (0-12), dd is the day of the month (1-31), and yyyy is the year. The ISO 8601 date format yyyy-mm-dd is also accepted.

Please let me know if my understanding of the -tt option is incorrect. If -tt option does not work the way I expected it, how else can I achieve my objective without resorting to unzip/delete/zip again process?

Thanks in advance for the help.
 
Old 04-25-2011, 09:52 PM   #2
gentisle
Member
 
Registered: May 2005
Location: USA
Distribution: LinuxMint
Posts: 167

Rep: Reputation: 6
I'm not a zip expert, however, from reading the help printed from zip, it looks like you are pitting one zip option against the other. The -d does delete, but the -tt is for including into an archive you are creating. So it sounds like the -d option "overrides" the -tt option.

Code:
Date filtering:
  -t date   exclude before (include files modified on this date and later)
  -tt date  include before (include files modified before date)
  Can use both at same time to set a date range
  Dates are mmddyyyy or yyyy-mm-dd
I think you need to write a script that deletes based on your date specs.
 
1 members found this post helpful.
Old 04-26-2011, 06:21 PM   #3
Arun Gupta
LQ Newbie
 
Registered: Apr 2011
Posts: 3

Original Poster
Rep: Reputation: 0
I have modified scripts to use rar instead of zip. It can do date/duration based deletes. Thanks...
 
Old 04-26-2011, 07:48 PM   #4
gentisle
Member
 
Registered: May 2005
Location: USA
Distribution: LinuxMint
Posts: 167

Rep: Reputation: 6
BTW, have you tried 7-zip for archiving? My tests show that it compresses better, but I haven't tried rar.
 
Old 04-27-2011, 07:06 PM   #5
Arun Gupta
LQ Newbie
 
Registered: Apr 2011
Posts: 3

Original Poster
Rep: Reputation: 0
I use 7-zip on Windows desktop. Never used it on Linux. The problem is that I am not permitted to use any freeware on the Linux servers without going through a complicated maze of obtaining permissions from security team.

We already have licenses for rar since I have been using it on Windows servers for last 5 years. The rar archive can be opened using WinZip. I am not sure about the 7z format. Sometimes I have to send the archive files to third parties.

In terms of program options, I can safely say that rar is the more feature rich than 7-zip or zip. I have converted my script to use rar instead of zip and it worked as expected.

Thanks...
 
  


Reply

Tags
zip


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
[SOLVED] BASH read text list zip files into a single archive --possible? SilversleevesX Programming 9 03-10-2014 02:43 AM
How to zip several files to several zip with one command? thomas2004ch Linux - Newbie 4 02-08-2010 08:13 AM
Archive manager not recognising ZIP files - suggests it's a text file. AnanthaP Ubuntu 4 12-27-2007 07:10 AM
Script to Add files to a Zip archive with out unzipping it !! prashix Programming 12 10-23-2007 09:19 AM
What Are archive.zip files? kajensen Linux - General 1 09-21-2003 04:00 AM


All times are GMT -5. The time now is 03:47 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration