On a prior page we spake of ‘tail -f’, dash eff, and its sublime abilities in watching the Lines of an e’er-growing File. We oft wield this deft implement, especially when looking at logges, as from stdout or Apatche or Railes. Yet the flow therefrom may make us quail, as the data pours o’er us faster than profane names pour from the blacksmith o’er the white cat he finds forever under-foot.

What can staunch this torrent? To be sure, ye may pipeth it through ‘cut’, yet while that reduces the quantity somewhat, still it pours forth each and every Line. The filter we need for this task, to ajoin to the end of this pipe, is ‘grep’. We’ve discoursed upon this fine instrument previously as well.

ℜ> tail -f server.logge | grep wine 12:00 Brother Farfellon: 1 flagon wine 12:02 Father Barbidgeton: 1 flagon wine 12:13 Brother Farfellon: 1 flagon wine 12:13 wine cask emptied - Brother Farfellon 12:15 new wine cask opened & found to be fair 12:22 Brother Farfellon: 1 flagon wine ℜ> _
The Creation of Birds and Fishes

This is fine and well useful, yet there is more on offer. Of course ye may avail yourself of the usual ‘grep’ Options, such as ‘-i’, dash eye, to ignore the case of thy search. We may also often wish to search for multiple Things upon the Lines thus filtered, and there be more than one way to accomplish this. The first may be done if the order of your multiple Things is always the same, and that is to simply search with a Regular Expression that may matcheth your quarry. Id est,

ℜ> tail -f server.logge | grep "Farfellon.*wine" 12:31 Brother Farfellon: 1 flagon wine 12:42 Brother Farfellon: 1 flagon wine 12:55 Brother Farfellon: 1 flagon wine ℜ> _

Sometimes the order is less predictable, or we want to match several different terms. Then does the Option ‘-e’, dash ee, come to hand. It can be used once, twice, a hundred times, all in the same invocation. Id est,

ℜ> tail -f server.logge | grep -e wine -e Farfellon 01:10 Brother Farfellon: 1 flagon wine 01:10 wine cask emptied - Brother Farfellon 01:18 Brother Farfellon: asleep under trestle ℜ> _
Five Birds (Hoopoe) Plucking the Feathers of Another Bird

Lastly, a tip if ye find yourself stringing very many of these pipes together one after another after ‘tail’. The stdout and stdin flowing between is buffered to save Resources, but it may be that this delays the results ye seek. If thy desire is to pipe thy ‘grep’ output along to another Tool, then use the Option ‘--line-buffered’, ‘dash dash line buffered’. This flushes the ‘grep’ output through yon pipes without delay. Id est,

ℜ> tail -f server.logge | grep --line-buffered wine | cut -d" " -f2,3 01:20 Brother Barbidgeton 01:22 Father Paternoster 01:23 Brother Farfellon 01:24 Brother Farfellon ℜ> _

Ctrl-D, Amen.

The Creation of Birds and Fishes, about 1360 - 1370, French
Five Birds (Hoopoe) Plucking the Feathers of Another Bird, about 1270, Franco-Flemish
Digital images courtesy of the Getty’s Open Content Program

~ this page pub. 23 February 2014 ~
« previouse page: Sponsors ~ Table of Contentes ~ next page: Wyld Kingdom: hedgehogs »