This guide will show you how to exclude certain folders and its sub-folders from zip in linux.
If you want to zip a folder with few sub-folders under it and you would like to exclude some folders from it then how can you do it. Below is a scenario and steps.
For Exa: There is a folder
/home/John/Maindata
Now folder "Maindata" has another 5 sub-folders like:-
/home/John/Maindata
/home/John/Maindata/New1
/home/John/Maindata/New2
/home/John/Maindata/New3
/home/John/Maindata/New4
/home/John/Maindata/New5
Now if we would like to exclude sub-folder "New1" and "New3" from zip, then below are the steps.
Open text editor (Gedit / Leafpad)
Copy-Paste the below given commands in it and save with "Filename.sh"
__________________________________________________________
#!/bin/bash
echo "processing......Please wait !!" ##this is just to show a msg
zip -r Maindata.zip /home/John/Maindata -x *New1* *New3*
echo "Completed"
___________________________________________________________
Open terminal and write the below command
> chmod +x "filename.sh" (press enter / return key)
>
This will make the file executable which can help for one-click / automated tasks.
Now run that file and it will create a zip file name - "Maindata.zip" which will have folders like this:-
Maindata.zip
|
New2
|
New4
|
New5
So this will exclude sub-folders - "New1" and "New3" from zip process.
No comments:
Post a Comment