Link to home
Start Free TrialLog in
Avatar of Bandai2
Bandai2

asked on

How to zip certain folders only using SSH & Putty?

I have a file structure like this on one of the servers I'm working on online:

foldera/
 -subfoldera/
 -filexx.xx
 -filexxx.xx
folderb/
folderc/
folderd/
foldere/
folderf/
file1.xx
file2.xx
file3.xx

I would like to put all files and folders and the contents inside each folder except for folderc in one zip file name bd.zip

How can I do this in SSH using Putty?
Avatar of Adrian Cantrill
Adrian Cantrill
Flag of Australia image

zip -r name.zip foldera/* foldrb/* folderc/* folderd/* foldere/* folderf/* file1.xx file2.xx file3.xx
ahh sorry didnt see the folderC exclusion

zip -r name.zip foldera/* folderb/* folderd/* foldere/* folderf/* file1.xx file2.xx file3.xx
and the name.zip should obviously be bd.zip
Avatar of Bandai2
Bandai2

ASKER

I have to type the folder names and file names one by one? Is there no other way to do this? I have like over 50 folders and files are over a hundred.. I just need to exclude a couple of folders from the zip file..

Also the file structure above is also inside another folder, so maybe that would help..
Ok well you could do

zip -r bd.zip * -x folderc/* etc etc

i.e add the whole tree but exclude a number of files/folders with the -x.
Avatar of Bandai2

ASKER

zip -r bd.zip * -x folderc/* etc etc

this only work with files.. it still include the folders I excluded.
ASKER CERTIFIED SOLUTION
Avatar of Adrian Cantrill
Adrian Cantrill
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial