- Reading time: 1 min
- Published 5 years ago
This may be common knowledge to almost everyone but I only recently discovered the
nl tool from GNU coreutils. Now, as long as the code listings to be done are to be published online - woah, that was some weird language - there's plenty of options to get them to have line numberings. GitHub's Gists do that. Almost all the syntax highlighting plugins for all the publishing platforms do that. So well. But there are situations where there is no such thing. At least not as conveniently available. Let's say you're writing a paper in TeX and need to embed a piece of code including line numberings. There is probably some kind of weird tex sorcery around that would do that for you. But there's also
nl available via any* unix-y command line. Give that a stream of text, get a stream with line endings back. Quick. Easy. Awesome.