Review your favorite Linux distribution.
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 01-16-2011, 07:12 PM   #1
LQ Newbie
Registered: Jan 2011
Posts: 2

Rep: Reputation: 0
Zipping multiple directories

Hi guys i have multiple directories as such


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 07:13 PM. Reason: bad formating
Old 01-16-2011, 07:17 PM   #2
Senior Member
Registered: Sep 2009
Location: Orange County, CA
Distribution: Kubuntu x64, Raspbian, CentOS
Posts: 1,856
Blog Entries: 36

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

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

Original Poster
Rep: Reputation: 0
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...
for x in `ls -w 1`;do zip -r $ $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, 07:33 PM   #4
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,233

Rep: Reputation: 404Reputation: 404Reputation: 404Reputation: 404Reputation: 404
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 '' 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 07:38 PM.


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

All times are GMT -5. The time now is 11:47 AM.

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