File tree Expand file tree Collapse file tree 2 files changed +29
-1
lines changed Expand file tree Collapse file tree 2 files changed +29
-1
lines changed Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ pairing with smart people at Hashrocket.
1010
1111For a steady stream of TILs, [ sign up for my newsletter] ( https://crafty-builder-6996.ck.page/e169c61186 ) .
1212
13- _ 1279 TILs and counting..._
13+ _ 1280 TILs and counting..._
1414
1515---
1616
@@ -1222,6 +1222,7 @@ _1279 TILs and counting..._
12221222- [ Curl With Cookies] ( unix/curl-with-cookies.md )
12231223- [ Curling For Headers] ( unix/curling-for-headers.md )
12241224- [ Curling With Basic Auth Credentials] ( unix/curling-with-basic-auth-credentials.md )
1225+ - [ Different Ways To Generate A v4 UUID] ( unix/different-ways-to-generate-a-v4-uuid.md )
12251226- [ Display All The Terminal Colors] ( unix/display-all-the-terminal-colors.md )
12261227- [ Display Free Disk Space] ( unix/display-free-disk-space.md )
12271228- [ Display The Contents Of A Directory As A Tree] ( unix/display-the-contents-of-a-directory-as-a-tree.md )
Original file line number Diff line number Diff line change 1+ # Different Ways To Generate A v4 UUID
2+
3+ There have been times where I have needed a random UUID. Usually if I am
4+ mocking some data or testing something out that needs a value in the shape of a
5+ UUID. Here are a couple different ways to do this in the terminal, as
6+ one-liners.
7+
8+ With ` ruby ` and the ` SecureRandom ` class:
9+
10+ ``` bash
11+ $ ruby -e " require 'securerandom'; puts SecureRandom.uuid"
12+ 29e52b97-b43d-4025-a43d-70053b1d1a63
13+ ```
14+
15+ With ` psql ` and the ` gen_random_uuid() ` function:
16+
17+ ``` bash
18+ $ psql -Xqtc ' select gen_random_uuid()' postgres | xargs
19+ 5a925ebd-c85f-4d94-a81e-e229c4cbe99f
20+ ```
21+
22+ With the ` uuidgen ` function that ships with Unix/Linux OSs:
23+
24+ ``` bash
25+ $ uuidgen
26+ B11555D8-A256-4EC8-A0B0-9259FF88C3FC
27+ ```
You can’t perform that action at this time.
0 commit comments