Help answer threads with 0 replies.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  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
LQ Guru
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

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

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
LQ Guru
Registered: Nov 2006
Location: Belgium
Distribution: Ubuntu 11.04, Debian testing
Posts: 5,019

Rep: Reputation: 130Reputation: 130
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.


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
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 > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:15 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration