Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
i dont want to remove the entire directoly only those files from the directoly which are zipped.. because everyday some or the other files are generated...
Your best bet is to create a bash script that moves files to be zipped to a separate directory, zip them, and then delete them. This would allow your main directory to continue to collect new files and not be mixed with those that you have already zipped and will be deleted.
Create a file called zipper.sh (or something like that) and make it executable:
chmod 755 zipper.sh
Using an editor of choice add the following (swapping out your directory and file names) in the directory just above those you'll be working with (ie. /usr/local):
but the problem is i cant move the files (change the path), becoz i m using those files later on..otherwise i will have to change the path in all the script..
what this option zip -n does
Here is the help piece printed out from zip. It looks like you're going to need to distinguish already zipped files from those that have not been.
-n allows you to specify a list of suffixes (ie. .txt, .exe, .pdf, etc.) to not compress.
-i and -x allow you to include or exclude in a similar fashion.
If you want to go off of whether the the file is new or changed then use the -u flag.
-------------------------------------------
Copyright (C) 1990-1999 Info-ZIP
Type 'zip "-L"' for software license.
Zip 2.3 (November 29th 1999). Usage:
zip [-options] [-b path] [-t mmddyyyy] [-n suffixes] [zipfile list] [-xi list]
The default action is to add or replace zipfile entries from list, which can include the special name - to compress standard input.
If zipfile and list are omitted, zip compresses stdin to stdout.
-f freshen: only changed files
-u update: only changed or new files
-d delete entries in zipfile
-m move into zipfile (delete files)
-r recurse into directories
-j junk (don't record) directory names
-0 store only
-l convert LF to CR LF (-ll CR LF to LF)
-1 compress faster
-9 compress better
-q quiet operation
-v verbose operation/print version info
-c add one-line comments
-z add zipfile comment
-@ read names from stdin
-o make zipfile as old as latest entry
-x exclude the following names
-i include only the following names
-F fix zipfile (-FF try harder)
-D do not add directory entries
-A adjust self-extracting exe
-J junk zipfile prefix (unzipsfx)
-T test zipfile integrity
-X eXclude eXtra file attributes
-y store symbolic links as the link instead of the referenced file
-R PKZIP recursion (see manual)
-h show this help
-n don't compress these suffixes
-------------------------------------------
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.