Siva Ram
Siva Ram

Reputation: 1

Zip subfolders using shell script

I want to zip the subfolders present under a folder using a shell script. For instance, I've tried to use a for loop such as the following

for i in */; do **commands to zip**

But it's not working as intended. What's a good way to accomplish this task?

Upvotes: 0

Views: 616

Answers (1)

Conner
Conner

Reputation: 31040

You could do this with a for loop, but I find it simpler with the find command. For example:

find . -type d -maxdepth 1 -exec zip -r {}.zip {} \;

This will find all subdirectories that are present in the top level directory and perform a recursive zip on each of them.

Upvotes: 1

Related Questions