Thursday, 22 October 2026

Using grep, awk, sed, sort, and uniq in combination

So I was trying to retrieve some information out of a log, and just for funsies, I thought I'd write it down here, so I remember what I did.

In short:

So I was trying to get a list of UUIDs of messages that failed to be parsed.

The serverlog I had contained for example the following:

Error during processing of message 8748 (225abd00-a806-455e-b3ef-a991c163fd41).
grep "Error during processing of" server.log | awk '{print $7}' | sed 's/(// ; s/)// ; s/\.//' | sort | uniq

Short explanation:

  • grep - only pick the lines containing that string
  • awk - print the 7th column with a standard delimiter of white space (" ")
  • sed - replace opening brackets ("("), closing brackets (")") and periods (".") from the output
  • sort - sort all alphabetically
  • uniq - make sure there are no duplicates

The result should be a list of UUIDs.

Footnote 1: the sort is essential, as uniq only works on adjacent lines

Footnote 2: yes, I know I can grep inside of an awk commando, but I am more familiar with grep and this is more fun.

Footnote 3: I've tested this on my MacBook. Linux might in some cases have different syntax.

Sunday, 20 September 2026

11 Laws

Found some laws in [1]. I thought I should write them down.

Parkinson's Law
Working spans to fill the time you give it. Shrink the deadline, shrink the task.
Hofstadter's Law
Everything takes longer than you expect, even when you account for Hofstadter's law.
Hanlon's Razor
Never attribute to malice what can be adequately explained by carelessness or stupidity.
The Pareto Principle (80/20)
Roughly 80% of the result comes from 20% of the effort.
The Peter Principle
People get promoted until they reach a job they're bad at. Then they stay there.
Hick's Law
More options mean slower decisions. Cut the menu, decide fast.
Goodhart's Law
When a measure becomes a target, it stops being a good measure.
The Dunning-Kruger Effect
The less you know the more you overestimate how much you know.
Occam's Razor
The simplest explanation is usually the right one.
Chesterton's Fence
Don't tear something down, until you understand why it was built in the first place.
Brooks's Law
If you add more people to a project that is already late, it's going to be more late. Because we underestimate coordination efforts.

Addendum: Parkinson's Law of Triviality is a different well-known one (of the same Mr. Parkinson, see [2]) regarding a bicyle shed and a nuclear power plant.

References

[1] Youtube - 11 Laws of the Universe
https://www.youtube.com/shorts/DRX5JpyX0B8
[2] Wikipedia - Law of triviality
https://en.wikipedia.org/wiki/Law_of_triviality