LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Zipping multiple directories (https://www.linuxquestions.org/questions/linux-newbie-8/zipping-multiple-directories-856719/)

Wastedsanity 01-16-2011 07:12 PM

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.

sag47 01-16-2011 07:17 PM

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;

Wastedsanity 01-16-2011 07:23 PM

Quote:

Originally Posted by sag47 (Post 4226693)
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?

frieza 01-16-2011 07:33 PM

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)


All times are GMT -5. The time now is 05:41 PM.