Random UUID is great when you need to generate a file with a temporary filename and avoiding file naming conflict.

Bash

No additional installation required for Bash, just run the command below.

uuidgen

Ruby

No additional installation required for Ruby too. Just copy the codes below into “uuid.rb”.

require 'securerandom'
puts SecureRandom.uuid

Use the command below to execute the Ruby script.

ruby uuid.rb

Go/Golang

The component to generate UUID does not come preinstalled together with the standard installation of Go/Golang. You’ll need to install the package by running the command below.

go get github.com/google/uuid

Paste the content below into “uuid.go”.

package mainimport (
"fmt"
"github.com/google/uuid"
)
func main(){
fmt.Println(uuid.New())
}

Use command below to run it.

go run uuid.go

< Back to all the stories I had written

Written by

A software engineer, a rock climbing, diving & rollerblading enthusiast, a husband, a father.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store