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.
Remove (delete) entries from a zip archive.
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.
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.
I have modified scripts to use rar instead of zip. It can do date/duration based deletes. Thanks...
BTW, have you tried 7-zip for archiving? My tests show that it compresses better, but I haven't tried rar.
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.
|All times are GMT -5. The time now is 07:23 PM.|