DEV Community

y4u
y4u

Posted on

sort | uniq -c | sort -rn, Now a GUI Button: Ranking 10,967 Hits' Top Values in 22 ms

Part 3 of bringing grep culture into my huge-file viewer. After -v (NOT filters) and -w (whole-word match), this time it's the whole one-liner:

grep Tokyo big.log | grep -oE '...' | sort | uniq -c | sort -rn | head -20
Enter fullscreen mode Exit fullscreen mode

That pipe now lives in UwView Pro's drill-down search as Tally, shipped in v1.5.0 alongside the other two.

On real data

OpenStreetMap Japan XML, 892,239,125 lines. Stage 1: Tokyo10,967 hits. Type k="([^"]+)" into the Tally field, press the button, and the first capture group gets counted in one pass over the hit lines:

10,967 matches / 159 distinct / 22 ms. Top of the ranking: name:en 4,848 (44.2%), operator:en 1,909 (17.4%), name:es 1,255 (11.4%). So 44% of the Tokyo lines are English name tags — invisible while scrolling, obvious as a table. Top-N adjustable (default 20), CSV export included.

The 22 ms is the scan over 10,967 already-narrowed hit lines, not over all 892 million — that's the honest reason it's fast.

The part uniq -c can't do

The tedium of uniq -c starts after the counting: "name:es has 1,255? Show me those lines" means rebuilding the pipe. In Tally, clicking a ranking row drills into that value as the next search stage — tally → value → raw lines is a click round-trip, and every stage stays behind as a tab.

CLI UwView Pro
`grep -oE 'k="[^"]+"' \ sort \
{% raw %}head -20 Top-N, default 20
> tally.csv Save CSV
(rebuild the pipe) click a row to drill down

Close, not identical: the key is the regex's first capture group (no capture → whole match), and counting details differ between tools.

Honest limits

  • Screenshots are from the pre-release build, so small details may differ from v1.5.0
  • Counting is once per line, not per occurrence — so this is not "uniq -c compatible," just close; the upside is the ranking count always equals the drilled-down hit count. Distinct values cap at 200k (shown when hit)
  • Big stages stay usable: 7.0s over 3GB / 100M lines, 61.5s over 1.39M hits on the 48GB file
  • Frequency ranking only. No sums, averages, or charts — that's real analytics territory
  • Counts and timings are my own single-environment runs
  • For scripted pipelines, the CLI original remains the right tool. This is for interactive investigation
  • More CLI-flavored features are coming; the next one is being selected now

UwView Pro is on sale (Windows, macOS, Linux — one license covers all three; 14-day free trial — editing features included). Screenshots and full details:

https://uvp.y42u.net/en/blog/uvp-tally-uniq-c-drilldown-en/

Previous parts: grep -v & -w in a GUI

Top comments (0)