LinuxQuestions.org
Help answer threads with 0 replies.
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, 02: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, 03:07 AM   #2
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 670Reputation: 670Reputation: 670Reputation: 670Reputation: 670Reputation: 670
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 03:19 AM.
 
Old 06-03-2007, 03: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, 03:52 AM   #4
jay73
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.
 
  


Reply


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 12:46 PM
zip files cooldudeguy Linux - Software 2 10-24-2004 03:57 AM
*.zip files e1000 Linux - Software 2 12-30-2003 11:40 AM
Zip Files linuxsoundprob Linux - Software 8 08-26-2003 07:34 AM
.zip Files Wynd Linux - Newbie 4 08-01-2001 01:47 PM


All times are GMT -5. The time now is 06:07 AM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration