LinuxQuestions.org
Review your favorite Linux distribution.
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-03-2007, 01:08 AM   #1
Russ S.
LQ Newbie
 
Registered: Jun 2006
Location: North Carolina
Distribution: Sidux
Posts: 26

Rep: Reputation: 15
How can I zip all the files in a directory?


I have a bunch of files in a single directory, that I need to have a .zip extension, not .gz, how can I do this without zipping each file individually?
 
Old 06-03-2007, 02:07 AM   #2
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
If there aren't any subdirectories, you could use
for file in *; do
zip "${file}.zip" "${file}"
done

If there are directories or special files (like sockets or links) you can use find to just handle regular files in the current directory:
find ./ -maxdepth 1 -type f -exec zip '{}'.zip '{}' \;

Last edited by jschiwal; 06-03-2007 at 02:19 AM.
 
Old 06-03-2007, 02:28 AM   #3
Russ S.
LQ Newbie
 
Registered: Jun 2006
Location: North Carolina
Distribution: Sidux
Posts: 26

Original Poster
Rep: Reputation: 15
Many thanks! I would have never figured that out lol.
 
Old 06-03-2007, 02:52 AM   #4
jay73
LQ Guru
 
Registered: Nov 2006
Location: Belgium
Distribution: Ubuntu 11.04, Debian testing
Posts: 5,019

Rep: Reputation: 133Reputation: 133
gz extensions are supported by most MS/commercial (un)zippers as well; it shouldn't make much of a difference whether you use zip or gzip. Only bzip2 has more limited support.
 
  


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
unzip all .zip files in a directory tes15 Linux - Newbie 14 08-29-2014 11:46 AM
zip files cooldudeguy Linux - Software 2 10-24-2004 02:57 AM
*.zip files e1000 Linux - Software 2 12-30-2003 10:40 AM
Zip Files linuxsoundprob Linux - Software 8 08-26-2003 06:34 AM
.zip Files Wynd Linux - Newbie 4 08-01-2001 12:47 PM

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

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