More in Text Processing
Sum a column with awk
Text Processing
Adds the third field of every line and prints the total, ignoring anything non-numeric.
Extract matches with a regular expression
Text Processing
grep -o prints only the matching part, which turns grep into a crude extractor.
Replace text across a whole project
Text Processing
ripgrep finds the files, sed edits them in place. The dry run first is not optional.
Pretty-print and query JSON
Text Processing
jq for the common cases: reformat, pick a path, filter an array, and reshape.
Sort and deduplicate lines by a field
Text Processing
Sorts on the second column and keeps the first row of each group.
A regular expression for ISO 8601 dates
Text Processing
Matches a date, optionally with a time and a zone. Deliberately strict about separators.
Random picks
Rotate links
wordpress
Rotate daily link order
Check a file's checksum
Security
Verifies a download actually matches what the publisher signed, rather than trusting the transfer.
A GitHub Actions workflow for a Node project
Build & CI
Caches the dependency install, runs on a matrix of versions, and fails the build on a lint error.
Delete duplicate rows, keeping the oldest
Databases
Uses a window function to number the duplicates and removes everything but the first of each group.
Records and pattern matching in Java
Systems
A record plus a switch pattern removes most of the ceremony this used to take.
Retry a fetch with exponential backoff
JavaScript
Backs off on each failure and adds jitter, so a recovering service is not hit by every client at the same moment.
Search the whole history for a string
Git
Finds every commit whose diff added or removed a piece of text, including in files long since deleted.
Deep clone a value
JavaScript
structuredClone handles Dates, Maps, Sets and cycles, which JSON round-tripping quietly destroys.