LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This 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


Reply
  Search this Thread
Old 05-27-2004, 11:50 PM   #1
suchi_s
Member
 
Registered: May 2004
Posts: 133

Rep: Reputation: 15
use of zip command


how to zip the files if the no of files are too large
 
Old 05-27-2004, 11:57 PM   #2
hallamigo
Member
 
Registered: Feb 2004
Location: Utah, USA
Distribution: Debian
Posts: 230

Rep: Reputation: 31
Not sure that I'm understanding, but if there are a lot of files you can always zip the directory that contains them.

zip myfiles.zip files/

If all else fails, zip them up in groups.

zip myfiles1.zip filesA/ filesB/
zip myfiles2.zip filesC/ filesD/
 
Old 05-28-2004, 12:16 AM   #3
suchi_s
Member
 
Registered: May 2004
Posts: 133

Original Poster
Rep: Reputation: 15
IN order to zip a directory containing files , do i need to specify the name of the files or just the name of the directory containing the files
 
Old 05-28-2004, 12:21 AM   #4
hallamigo
Member
 
Registered: Feb 2004
Location: Utah, USA
Distribution: Debian
Posts: 230

Rep: Reputation: 31
My bad, I forgot to mention that when you zip a directory you have to specify that you want to recurse into the directory(s).

Do the following if you want to zip a directory called files:

zip -r files.zip files/
 
Old 05-28-2004, 12:29 AM   #5
suchi_s
Member
 
Registered: May 2004
Posts: 133

Original Poster
Rep: Reputation: 15
again its giving an error that its too many arguments..
 
Old 05-28-2004, 12:34 AM   #6
hallamigo
Member
 
Registered: Feb 2004
Location: Utah, USA
Distribution: Debian
Posts: 230

Rep: Reputation: 31
Copy and paste what you're typing and the error it's throwing.
 
Old 05-28-2004, 12:43 AM   #7
suchi_s
Member
 
Registered: May 2004
Posts: 133

Original Poster
Rep: Reputation: 15
its working now... is there any command in combination , which removes the files which are zipped , becaz we have all those files in .zip file
 
Old 05-28-2004, 12:46 AM   #8
hallamigo
Member
 
Registered: Feb 2004
Location: Utah, USA
Distribution: Debian
Posts: 230

Rep: Reputation: 31
Yeah, you can always run the following WITH EXTREME CAUTION as it will delete the entire directory without asking if you're sure.

rm files/ -rf

I once accidently did this to my /usr directory and then spent the next few hours backing up and reinstalling everything.
 
Old 05-28-2004, 12:47 AM   #9
suchi_s
Member
 
Registered: May 2004
Posts: 133

Original Poster
Rep: Reputation: 15
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...
 
Old 05-28-2004, 12:58 AM   #10
hallamigo
Member
 
Registered: Feb 2004
Location: Utah, USA
Distribution: Debian
Posts: 230

Rep: Reputation: 31
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):

Code:
#!/bin/sh

mv /usr/local/files/* /usr/local/tozip
zip -r zipped.zip /usr/local/tozip
rm -rf /usr/local/tozip/*
echo "zipping complete"
Run the file from within the directory by typing:

./zipper.sh

Last edited by hallamigo; 05-28-2004 at 01:00 AM.
 
Old 05-28-2004, 01:03 AM   #11
suchi_s
Member
 
Registered: May 2004
Posts: 133

Original Poster
Rep: Reputation: 15
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
 
Old 05-28-2004, 01:13 AM   #12
hallamigo
Member
 
Registered: Feb 2004
Location: Utah, USA
Distribution: Debian
Posts: 230

Rep: Reputation: 31
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
-------------------------------------------
 
Old 05-28-2004, 01:15 AM   #13
suchi_s
Member
 
Registered: May 2004
Posts: 133

Original Poster
Rep: Reputation: 15
i think we can go for -m option
 
Old 05-28-2004, 01:16 AM   #14
hallamigo
Member
 
Registered: Feb 2004
Location: Utah, USA
Distribution: Debian
Posts: 230

Rep: Reputation: 31
Good luck, and remember to always automate - that's what programming is all about.
 
Old 05-28-2004, 01:18 AM   #15
suchi_s
Member
 
Registered: May 2004
Posts: 133

Original Poster
Rep: Reputation: 15
bash: /bin/rm: argument list too long...
while removing i m getting this error
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to Unzip 2 Zip files through one single command sumitarun Linux - Newbie 2 03-23-2005 08:00 AM
preserve file ownership with the "zip" command? zovres Linux - General 2 11-25-2004 09:01 PM
.zip help Jmcatch742 Linux - General 1 11-16-2004 09:07 PM
create a self-extracting zip file with zip on solaris? samsolaris Solaris / OpenSolaris 3 10-15-2004 01:50 AM
Mounting a zip disk command. jtp51 Linux - General 4 02-19-2003 09:38 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

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

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