# Compress files and folders

## Zip

Collect and compress files and directories into a zip file

```
zip -r <output-file> <source-files>
```

Unzip a standard zip file archive

```
unzip <file>
```

List files contained inside zip file without extracting

```
unzip -l <file>
```

## Zip Info

Show files contained in zip file (`-m` show compression rate)

```
zipinfo <file>
zipinfo -m <file>
```

List directory and file names only

```
zipinfo -1 <file>
```

## Gzip

Gzip file and keep (`-k`) original source file

```
gzip <file> -k
```

Gzip file contents and write to stdout (useful for piping / directing results)

```
gzip <file> -c
gzip <input-file> -c > <output-file>
```

## Tar

Tar (collect) and Gzip the specified directory to file.tgz

```
tar -czvf <file.tgz> <directory>
```

Uncompress file.tgz

```
tar -xzvf <file.tgz>
```

## Brotli

Install brotli command line processor

```
brew install brotli
```

Compress file with brotli (defaults to keep source and maximum compression)

```
brotli <file>
```


---

# 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://refdocs.buymeasoda.com/unix/compress-files-and-folders.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.
