uuidgen - macOS


Overview

uuidgen is a macOS command-line tool that generates universally unique identifiers (UUIDs). It is primarily used for creating unique identifiers for system components, files, and other entities.

Syntax

uuidgen [options]

Options/Flags

  • -r: Generate a random UUID (default)
  • -t: Generate a UUID based on the current time
  • -u: Generate a UUID based on the user’s identity

Examples

Generate a random UUID:

uuidgen

Generate a time-based UUID:

uuidgen -t

Generate a UUID based on user identity:

uuidgen -u

Common Issues

  • Empty output: Make sure the command is invoked with the correct syntax and options.
  • Invalid UUID format: Check if the generated UUID follows the standard format (e.g., xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx).

Integration

uuidgen can be combined with other commands for advanced tasks:

Create a UUID-named file:

uuidgen | xargs touch

Pass UUID as argument:

python3 script.py $(uuidgen)