Skip to content

Instantly share code, notes, and snippets.

@bact
Created June 23, 2024 14:16
Show Gist options
  • Save bact/b9ccf6bfdfdc30b8947d3d90401f8d34 to your computer and use it in GitHub Desktop.
Save bact/b9ccf6bfdfdc30b8947d3d90401f8d34 to your computer and use it in GitHub Desktop.
Generate UUIDv4 with specific prefix
#!/bin/bash
amount=$1
regex=$2
echo "Generating $amount UUIDs with $regex..."
count=0
while [ $count -lt $amount ]; do
uuid=$(uuidgen | awk '{print tolower($0)}')
if [[ $uuid =~ ^$regex ]]; then
echo $uuid
((count++))
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment