#!/bin/sh set -eu usage() { cat <<-'EOF' Usage: uuid uuid -h EOF } help() { cat <<-'EOF' Options: -h, --help show this message Generate UUID from /dev/urandom. Examples: Generate a UUID: $ uuid 755244c8-f955-16df-75cc-f25600c90422 EOF } for flag in "$@"; do case "$flag" in (--) break ;; (--help) usage help exit ;; (*) ;; esac done while getopts 'h' flag; do case "$flag" in (h) usage help exit ;; (*) usage >&2 exit 2 ;; esac done shift $((OPTIND - 1)) od -xN20 /dev/urandom | awk 'NR == 1 { OFS="-"; print $2$3,$4,$5,$6,$7$8$9; exit }'