Skip to Content

Massively explains Warhammer Online to the dedicated WoW player
AOL Tech

Filed under: Tips and tricks, Odds and ends, Terminal Tips

Terminal Tip: the joy of nl

Too often overlooked, nl provides a very useful shell command. As you can see here, when issued, it numbers the lines of a text file. But that's certainly not all that this little utility can do. My favorite feature allows you to count the occurrences of a regular expression. Use the -bp flag to tell nl to count all the lines that match that expression. For example:

% nl -bp"So.*e" sonnet.txt
Shall I compare thee to a summer's day?
Thou art more lovely and more temperate:
Rough winds do shake the darling buds of May,
And summer's lease hath all too short a date:
1 Sometime too hot the eye of heaven shines,
And often is his gold complexion dimm'd;
And every fair from fair sometime declines,
By chance or nature's changing course untrimm'd;
But thy eternal summer shall not fade
Nor lose possession of that fair thou owest;
Nor shall Death brag thou wander'st in his shade,
When in eternal lines to time thou growest:
2 So long as men can breathe or eyes can see,
3 So long lives this and this gives life to thee.
%

Recent Posts

Reader Comments (Page 1 of 1)

Tip of the Day

Catch all of TUAW's ongoing Macworld coverage at www.tuaw.com/macworld2009


Follow us on Twitter!

Sponsored Links

Featured Galleries

DNC Macs
Macworld 2008 Keynote
Macworld 2008 Build-up
Google Earth for iPhone
Podcaster
Cucchiaio d'Argento
Scrabble for iPhone
Apple Vanity Plates
Apple booth Macworld 07
DiscPainter
2009CupertinoBus
Crash Bandicoot Nitro Kart 3D
Macworld Expo 2007 show floor
Apple Texas Hold 'Em
The Macworld Faithful in Line
iPhone First Look
Facebook 2 for iPhone
TUAW at Macworld 2009 -- North Hall
2009 Macworld Day One
Beejive 2.0
Aurora Feint

 

More Apple Analysis