Let say we have a directory structure like:
A
|---B
| |---C
| | |--f1.txt
| |
| |---D
| | |--f2.txt
|
|---E
| |---f3.txt
| |
|
|---F
| |---f4.txt
Now how to zip a file BE.zip excluding F directory, i.e when I unzip BE.zip the result should be:
|---B
| |---C
| | |--f1.txt
| |
| |---D
| | |--f2.txt
|
|---E
| |---f3.txt
The easiest way to zip a folder on Linux is to use the “zip” command with the “-r” option and specify the file of your archive as well as the folders to be added to your zip file. You can also specify multiple folders if you want to have multiple directories compressed in your zip file.
Locate the file or folder that you want to zip. Press and hold (or right-click) the file or folder, select (or point to) Send to, and then select Compressed (zipped) folder. A new zipped folder with the same name is created in the same location.
Syntax : $zip –m filename.zip file.txt 4. -r Option: To zip a directory recursively, use the -r option with the zip command and it will recursively zips the files in a directory. This option helps you to zip all the files present in the specified directory.
You can compress directories and the corresponding sub-directories by using the -r flag. The -r flag will tell zip to traverse the entire directory recursively. To suppress the output from the compression process, use the -q for quiet mode. The command creates a zip archive of the specified files with no output.
ok got it..
zip -r BE.zip B/ E/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With