As the goatherd counts his flock, as the peahen counts her peachicks, as Cook counts whom had two servings of mincemeat at Yule, so we oft needs count the Lines within our Files. The commonest tool for this task, and well may you know it, is ‘wc’, double-yew see. Named for a Wicked Child that we know not, it shows thee counts of Lines, Wordes, and Characters.
The last number, Characters, near always matches the File’s size as reported by ‘ls’, ell ess. The second number, Wordes, rarely do I find use of. But the first number, Lines, is first to mind, and fabulous useful. Ye may omit the unuseful numbers of Wordes and Characters: give ‘wc’ the Option ‘-l’, dash ell, and it will yield only the number of Lines. Id est:
Counting the total number of lines is well and goode. Yet on occasion ye may want to see the numbers of each Line in yon File. Assuredly these may be shown in ‘vi’: typeth ‘:set number’ to reveal them, and typeth ‘:set nonumber’ to conceal them again. But another tool may be found upon our worktable: ‘nl’, en ell, from the Latin, numerus lineus. Summon execution of this device with no options, naming a File, and behold: it numbers each Line that is not Blank or Empty or Vacant or Void. If thou desireth the Blank lines to also be number’d, then giveth the Option ‘-ba’, dash bee ay. Id est:
In this wide expanse of utensils which number our Lines, yet another should we chronicle. The tool we have written of before, the searcher and grabber, the one called ‘grep’. But it has yet another numerological Option that may aide thee well: use the Option ‘-n’, dash en, and ‘grep’ will reveal all the matching Lines, each accompanied by its line-number. Id est:
Ctrl-D, Amen.