Skip to content

uuidgen MacOS Command Guide

The MacOS uuidgen command generates and prints a unique identifier using the UUID library. This command creates a new universally unique identifier (UUID) in a standard format. UUIDs are 128-bit numbers that guarantee uniqueness across space and time. The generated UUIDs can be useful in various scenarios, such as generating unique file names, database keys, or tracking unique items. The uuidgen command on MacOS allows for easy generation of UUIDs without the need for external libraries or tools.

Terminal window
uuidgen
OptionDescription
-hdrPrint UUID in human-readable form.
-t timeGenerate time-based UUID.
-sGenerate random-based UUID.
-n nsGenerate name-based UUID (namespace is a UUID).

There are no parameters for the uuidgen command.

Terminal window
uuidgen

Generates a random UUID.

Terminal window
uuidgen -U -n5

Generates 5 random UUIDs in uppercase.

Terminal window
uuidgen -h

Generates a random UUID without hyphens.

Generate a UUID for use in the Mac OS pasteboard

Section titled “Generate a UUID for use in the Mac OS pasteboard”
Terminal window
uuidgen | pbcopy

Generates a random UUID and copies it to the Mac OS pasteboard.

Terminal window
echo "file_$(uuidgen)" > new_file.txt

Generates a random UUID and appends it to a filename.

Terminal window
uuidgen -F '%A-%B-%C-%D-%E'

Generates a random UUID using a user-specified format.

Generate a UUID compatible with RFC4122 version 3

Section titled “Generate a UUID compatible with RFC4122 version 3”
Terminal window
uuidgen -r

Generates a UUID that is compatible with RFC4122 version 3.

To use the uuidgen command in MacOS, execute the following command:

Terminal window
uuidgen

What is the output format of uuidgen in MacOS?

Section titled “What is the output format of uuidgen in MacOS?”

The output format of uuidgen in MacOS is a standard UUID string in the following format:

Terminal window
6B29FC40-CA47-1067-B31D-00DD010662DA

Can I generate multiple UUIDs at once with uuidgen in MacOS?

Section titled “Can I generate multiple UUIDs at once with uuidgen in MacOS?”

Yes, you can generate multiple UUIDs at once with the -n option in uuidgen. For example:

Terminal window
uuidgen -n 5

How can I generate a UUID in uppercase format using uuidgen in MacOS?

Section titled “How can I generate a UUID in uppercase format using uuidgen in MacOS?”

To generate a UUID in uppercase format, you can use the -U option with uuidgen as shown below:

Terminal window
uuidgen -U

Is there a way to generate a UUID without hyphens in MacOS using uuidgen?

Section titled “Is there a way to generate a UUID without hyphens in MacOS using uuidgen?”

Yes, you can generate a UUID without hyphens in MacOS by using the -H option with uuidgen. Here’s an example:

Terminal window
uuidgen -H
  • Generating unique identifiers
  • Creating universally unique names
  • Generating random UUIDs for various purposes