> For the complete documentation index, see [llms.txt](https://book.bsdcn.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://book.bsdcn.org/man/man1/uuidgen.1.md).

# uuidgen.1

`uuidgen` — 生成通用唯一标识符

## 名称

`uuidgen`

## 概要

`uuidgen [-1cr] [-n count] [-o filename]`

## 描述

`uuidgen` 实用程序默认生成一个 DCE 版本 1 通用唯一标识符（UUID），也称为全局唯一标识符（GUID）。UUID 默认写入标准输出。以下选项可用于更改 `uuidgen` 的行为：

**`-1`** 此选项仅在需要生成多个标识符时生效，指示 `uuidgen` 不要批量生成，而是逐个生成。

**`-c`** 此选项控制创建紧凑格式的 UUID（不含连字符）。

**`-n`** 此选项控制生成的标识符数量。默认情况下，多个标识符以批量方式生成。

**`-o`** 将输出重定向到 `filename` 而非标准输出。

**`-r`** 此选项控制创建随机 UUID（版本 4）。

批量生成会产生一组密集的标识符，使得在该集合中不存在比集合中最小标识符大且比最大标识符小、但又不属于该集合的标识符。

逐个生成标识符时，各个标识符之间会彼此接近，但操作系统的延迟和处理时间会反映在两个连续标识符之间的差距上。

## 退出状态

`uuidgen` 实用程序成功时退出值为 0，发生错误时大于 0。

## 实例

生成一批三个 UUID。注意 UUID 第一个连字符之前的字符串（在 *rfc4122* 中称为 *time\_low*）的相似性：

```sh
$ uuidgen -n3
8bc44345-4d90-11ee-88c7-b42e991fc52e
8bc44346-4d90-11ee-88c7-b42e991fc52e
8bc44347-4d90-11ee-88c7-b42e991fc52e
```

生成一批不含连字符的随机 UUID：

```sh
$ uuidgen -r -c -n3
5ad8b60a0f4e41f59c82d273202275f9
6c41925486cd4bf59720a5bad85de2e4
8144fdab63f648a1812d12453f975313
```

注意这些 UUID 彼此之间并不相似。

## 参见

uuidgen(2), uuid(3)

## 历史

`uuidgen` 命令首次出现于 FreeBSD 5.0。


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://book.bsdcn.org/man/man1/uuidgen.1.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
