lwc
lwc copied to clipboard
A live-updating version of the UNIX wc command.
lwc
A live-updating version of the UNIX wc command.

Installation
You can get a prebuilt binary for every major platform from the
Releases page. Just extract it
somewhere under your PATH and you're good to go.
Alternatively, use go get to build from source:
go get -u github.com/timdp/lwc/cmd/lwc
On Debian-compatible Linux distributions such as Ubuntu, you can also use the experimental APT repository:
echo 'deb [allow-insecure=yes] https://tmdpw.eu/lwc-releases/debian/ any main' |
sudo tee /etc/apt/sources.list.d/lwc.list
sudo apt update
sudo apt install lwc
Usage
lwc [OPTION]... [FILE]...
lwc [OPTION]... --files0-from=F
Without any options, lwc will count the number of lines, words, and bytes
in standard input, and write them to standard output. Contrary to wc, it will
also update standard output while it is still counting.
All the standard wc options are
supported:
--linesor-l--wordsor-w--charsor-m--bytesor-c--max-line-lengthor-L--files0-from=F--help--version
In addition, the output update interval can be configured by passing either
--interval=TIME or -i TIME, where TIME is a duration in milliseconds.
The default update interval is 100 ms.
Examples
Count the number of lines in a big file:
lwc --lines big-file
Run a slow command and count the number of lines and words logged:
slow-command | lwc --lines --words
Benchmark lwc's throughput by counting random bytes (press Ctrl+C to exit):
lwc --bytes < /dev/urandom
Caveats
You can mostly use lwc as a drop-in replacement for wc. However, you
should be aware of the following:
-
The behavior of the
--wordsand--charsoptions is slightly different fromwc's implementation. You might get different values with certain binary data. -
While
lwcis pretty fast, you won't get the same raw throughput as withwc. The reason for that is (probably) twofold: the code isn't optimized for performance, and a Go implementation is no match for a C one.
JavaScript Version
This utility briefly existed as a Node.js package. I'm keeping the code around for educational purposes, but I will no longer be maintaining it.
Author
License
MIT