Uuid
uuid_nil¶
Return the RFC4122 nil UUID (all zeros).
Exit codes¶
- 0: Always
Output on stdout¶
- 00000000-0000-0000-0000-000000000000
uuid_v1¶
Generate a version 1 (time-based, MAC address) UUID. Uses uuidgen --time if available, otherwise generates from scratch.
Exit codes¶
- 0: Always
Output on stdout¶
- A version 1 UUID string
uuid_v2¶
Generate a version 2 (DCE Security) UUID. UUIDv2 is not implemented. The DCE Security UUID specification was never made public, implementations are incompatible, and the format is effectively defunct. Use uuid_v1 for time-based UUIDs or uuid_v4 for random UUIDs.
Exit codes¶
- 1: Always
uuid_v3¶
Generate a version 3 (MD5 namespace-based) UUID. Alias for: uuid_hash v3 namespace name
Arguments¶
- $1 (string): Namespace: @dns, @url, @oid, @x500, or @custom
- $2 (string): Name
Exit codes¶
- 0: Success
- 1: Missing namespace or name
Output on stdout¶
- A version 3 UUID string
uuid_v4¶
Generate a version 4 (fully random) UUID. Uses uuidgen --random, /proc/sys/kernel/random/uuid, or a bash-native fallback.
Exit codes¶
- 0: Always
Output on stdout¶
- A version 4 UUID string
uuid_v5¶
Generate a version 5 (SHA-1 namespace-based) UUID. Alias for: uuid_hash v5 namespace name
Arguments¶
- $1 (string): Namespace: @dns, @url, @oid, @x500, or @custom
- $2 (string): Name
Exit codes¶
- 0: Success
- 1: Missing namespace or name
Output on stdout¶
- A version 5 UUID string
uuid_v6¶
Generate a version 6 (reordered time) UUID. Functionally equivalent to v1 but with timestamp bits stored MSB-first, making v6 UUIDs lexicographically sortable. Prefer v6 over v1 for new work.
Exit codes¶
- 0: Always
Output on stdout¶
- A version 6 UUID string
uuid_v7¶
Generate a version 7 (Unix timestamp + random) UUID. Uses a 48-bit millisecond Unix timestamp followed by random bits, making v7 UUIDs lexicographically sortable without requiring a MAC address. Prefer v7 over v1/v6 for new work that doesn't need Gregorian-epoch time.
Exit codes¶
- 0: Always
Output on stdout¶
- A version 7 UUID string
uuid_v8¶
Generate a version 8 (custom) UUID. RFC 9562 mandates only the version and variant bits; the three custom fields (custom_a 48-bit, custom_b 12-bit, custom_c 62-bit) are implementation-defined. This implementation fills them with random data by default, producing a UUID that is distinguishable from v4 by version number. Callers with a specific encoding scheme can supply their own hex values for each field; any omitted field is randomised.
Options¶
- --custom-a
hex 48-bit custom field (up to 12 hex chars)
- --custom-b
hex 12-bit custom field (up to 3 hex chars)
- --custom-c
hex 62-bit custom field (up to 15 hex chars)
Exit codes¶
- 0: Success
- 1: Invalid arguments
Output on stdout¶
- A version 8 UUID string
uuid_pseudo¶
Generate a pseudo-UUID using od and /dev/urandom. Not RFC4122 compliant; useful for quick non-critical identifiers.
Exit codes¶
- 0: Always
Output on stdout¶
- A pseudo-UUID string
uuid_gen¶
Generate a UUID of the specified version (default: v4).
Arguments¶
- $1 (string): Optional: -0/-nil/-null, -1/--time, -2, -3/--md5, -4/-r/--random,
Exit codes¶
- 0: Success
- 1: Invalid arguments or unsupported version
Output on stdout¶
- A UUID string
uuid_switch_endian¶
Blindly convert a UUID between little-endian and mixed-endian (Microsoft) byte order. The first three octets are byte-swapped; the remainder are unchanged.
Arguments¶
- $1 (string): A valid UUID string
Exit codes¶
- 0: Success
- 1: No UUID supplied or invalid UUID structure/content
Output on stdout¶
- UUID with first three octets in reversed byte order
validate_uuid¶
Validate that a string is a structurally and content-valid UUID. Checks the 8-4-4-4-12 structure and that all characters are hexadecimal.
Arguments¶
- $1 (string): The UUID string to validate
Exit codes¶
- 0: Valid UUID
- 1: Invalid structure or non-hex characters found