Skip to content

Commit 2dcb0dd

Browse files
committed
Add Produce A Lowercase V4 UUID as a Unix TIL
1 parent 5f0d298 commit 2dcb0dd

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ pairing with smart people at Hashrocket.
1010

1111
For a steady stream of TILs, [sign up for my newsletter](https://crafty-builder-6996.ck.page/e169c61186).
1212

13-
_1334 TILs and counting..._
13+
_1335 TILs and counting..._
1414

1515
---
1616

@@ -1322,6 +1322,7 @@ _1334 TILs and counting..._
13221322
- [Print Milliseconds In Human-Readable Format](unix/print-milliseconds-in-human-readable-format.md)
13231323
- [Print Out Files In Reverse](unix/print-out-files-in-reverse.md)
13241324
- [Print The Current Date In Human-Readable Format](unix/print-the-current-date-in-human-readable-format.md)
1325+
- [Produce A Lowercase V4 UUID](unix/produce-a-lowercase-v4-uuid.md)
13251326
- [Provide A Fallback Value For Unset Parameter](unix/provide-a-fallback-value-for-unset-parameter.md)
13261327
- [Remove A Directory Called `-p`](unix/remove-a-directory-called-dash-p.md)
13271328
- [Repeat Yourself](unix/repeat-yourself.md)
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Produce A Lowercase V4 UUID
2+
3+
There are [a variety of ways to produce a v4
4+
UUID](different-ways-to-generate-a-v4-uuid.md) on Unix-based machines. Of the
5+
options I listed in that post, my favorite is the `uuidgen` command. My only
6+
gripe with it is that it produces an all uppercase UUID.
7+
8+
```bash
9+
$ uuidgen
10+
B7918C26-12AE-4093-B6DA-0D7D41C59FB6
11+
```
12+
13+
Often when I need a UUID, it is to plug in as the ID value for some test data
14+
in a system that is using lowercase UUIDs. For the sake of consistency, I'd
15+
like it to be lowercase as well.
16+
17+
The `tr` command comes in handy for this because I can _tr_anslate the
18+
uppercase characters to lowercase ones.
19+
20+
```bash
21+
$ uuidgen | tr '[:upper:]' '[:lower:]'
22+
ed817cf3-8f70-4838-82bc-8e5b328c0b93
23+
```
24+
25+
So now anytime I need a lowercase UUID, I hit `ctrl-r` and search back for
26+
either `uuid` or `lower` and find this command pretty quickly.

0 commit comments

Comments
 (0)