LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 01-16-2011, 08:12 PM   #1
Wastedsanity
LQ Newbie
 
Registered: Jan 2011
Posts: 2

Rep: Reputation: 0
Zipping multiple directories


Hi guys i have multiple directories as such

.../Claymore/1.001/
.../Claymore/1.002/
.../Claymore/1.003/
.../Claymore/etc...

How do I compress each directory inside /Claymore/ using the names of the directories for the names of the output tar or zip files.

Last edited by Wastedsanity; 01-16-2011 at 08:13 PM. Reason: bad formating
 
Old 01-16-2011, 08:17 PM   #2
sag47
Senior Member
 
Registered: Sep 2009
Location: Orange County, CA
Distribution: Kubuntu x64, Raspbian, CentOS
Posts: 1,845
Blog Entries: 36

Rep: Reputation: 453Reputation: 453Reputation: 453Reputation: 453Reputation: 453
I do basically what you want in my blog entry. The only part you would need would be this...
Code:
for x in `ls -w 1`;do zip -r $x.zip $x;done;

Last edited by sag47; 01-16-2011 at 08:19 PM.
 
Old 01-16-2011, 08:23 PM   #3
Wastedsanity
LQ Newbie
 
Registered: Jan 2011
Posts: 2

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by sag47 View Post
I do basically what you want in my blog entry. The only part you would need would be this...
Code:
for x in `ls -w 1`;do zip -r $x.zip $x;done;
do i just throw this into a terminal or do i have to do something else with it first?
 
Old 01-16-2011, 08:33 PM   #4
frieza
Senior Member
 
Registered: Feb 2002
Location: harvard, il
Distribution: Ubuntu 11.4,DD-WRT micro plus ssh,lfs-6.6,Fedora 15,Fedora 16
Posts: 3,202

Rep: Reputation: 397Reputation: 397Reputation: 397Reputation: 397
just in a terminal would work for a one shot use, i do something like that all the time, or you could save it in a text file named something like 'multizip.sh' and chmod +x the file so you can run it as a shell script from within the current directoyr (or move it somewhere in the path like /usr/bin or /usr/local/bin as root)

Last edited by frieza; 01-16-2011 at 08:38 PM.
 
  


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
cp multiple files to multiple directories Heksie Linux - Newbie 2 02-05-2009 06:17 AM
Recursively zipping directories AckSed Linux - Newbie 2 10-19-2007 08:29 PM
Change text in multiple files in multiple directories vivo2341 Linux - General 5 11-27-2006 09:16 PM
Searching multiple directories and sub directories for a file jeep99899 Linux - Newbie 2 10-13-2005 01:23 PM
Help I need help tarring multiple files in multiple directories VisionZ Linux - Newbie 28 03-25-2004 06:25 PM


All times are GMT -5. The time now is 07:26 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration