# zip

The `zip` command in Linux is commonly used for file compression and packaging. It allows you to create .zip files, which are compressed archives containing one or more files or directories. Here are the key functionalities and usage examples of the `zip` command:

1. **Creating Zip Archives**: To create a zip archive, use `zip` followed by the name of the archive you want to create, and then list the files or directories to be included. For example: `zip archive.zip file1.txt file2.txt` will create an archive named `archive.zip` containing `file1.txt` and `file2.txt`.
2. **Recursive Compression**: To include a directory along with all its subdirectories and files, use the `-r` (recursive) option. For instance: `zip -r archive.zip directoryname` will compress the entire directory named `directoryname` and its contents into `archive.zip`.
3. **Compression Levels**: `zip` allows specifying the compression level with `-0` (no compression) to `-9` (best compression). If not specified, `zip` uses a default compression level. Example: `zip -9 archive.zip file.txt` uses maximum compression for `file.txt`.
4. **Excluding Files**: If you want to exclude certain files from the zip archive, use the `-x` option. For example: `zip archive.zip * -x exclude.txt` will zip all files in the current directory except `exclude.txt`.
5. **Listing Zip Contents**: To view the contents of a zip archive without extracting it, use `zip -l archive.zip`. This command lists the files included in `archive.zip`.
6. **Adding Files to Existing Archive**: You can add files to an existing zip archive with the same `zip` command. For example, `zip archive.zip newfile.txt` adds `newfile.txt` to `archive.zip`.
7. **Splitting Zip Files**: For large archives, `zip` can split the file into smaller parts. This is done using the `-s` option followed by the size (e.g., `-s 100m` for 100 MB parts).
8. **Zip Options**: `zip` has many options for customization, like adjusting compression method, adding comments to archives, and more.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://www.cs1.dev/linux/zip.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
