-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Wednesday, 2013-04-03 at 10:26 -0400, Anton Aylward wrote:
Carlos E. R. said the following on 04/03/2013 10:03 AM:
Ok, but the man page does not say how to tell grep not to look inside not normal files :-)
Ah, so you want a Swiss army knife?
:-) Ah, Dave posted the trick a minute ago :-) About grep and the Swiss army knife... I'm used to a special "grep" version made by Lucent Technologies (previous AT&T") that was named "cgrep". It is now available as free (well, actually "Lucent Public License"), sometime after the demise of Lucent and the disappearance of Bell Labs. This switch is what made it of particular use to me: 5ESS Project-Specific Options The following special-purpose options are provided for the convenience of those analyzing 5ESS International or Domestic ROP reports. -R Sets window delimiters and other options for 5ESS International or Domestic ROP reports. The -R option can also be used in conjunction with -nline or +nline to output preceding or subsequent ROP reports to the matched report, or both. In either case, nline-1 adjacent reports will also be printed. The -R option is almost equivalent to -DEMh +I2 -+w ´\+\+\+|^Y´ , but has one additional effect. Patterns of the form ´sm=n´ (the literal sm must be in lower case letters) will be expanded into regular expressions to match most if not all ROP reports pertaining to SM n. n must be an unsigned number without leading zeros, in which each digit may be either a simple digit or any one of a set of digits enclosed in square brackets. Within brackets, a hyphen can be used to indicate a range of digits. See the 5ESS EXAMPLES sec- tion for examples of the use of this feature. -T Same as -R, except also causes ROP event trails to be followed. If the string "EVENT=n" (n is a number of one or more digits, possibly preceded by a minus sign) or "EVENTO=n" (Spanish) appears in a matched ROP report, all subsequent reports with the same event number will be printed. Equivalent to the following: -R -t ´EVENTO?=-?[0-9]+´ . It is not the only addition. There are powerful options to capture context around a particular string found in the text, both before and after the match. I have used that feature in scripts of mine. The man page says that the author is "Bill Tanenbaum". The web page at the time I got the public version were these, according to the man page: http://www.bell-labs.com/project/wwexptools/cgrep/ Source Code, etc. http://www.bell-labs.com/cgi-user/wwexptools/gensnapshot?cgrep
It reminds me of Rob Pike's "considered harmful" view of what Berkeley did to 'cat'
I agree with the 'each thing should do one things and only one thing' approach to tool building. Not only does it make combining tools easier - the great power of UNIX is scripting, notable the shell -but each thing can be proven to be 'correct'.
True. Mmmm... systemd? >:-)
If you can make this case for grep then you can make it for cat and tr and many other programs.
X'-)
Perhaps you want to re-invent one of the mainframe OS's of the 50s and 60s?
Argh, 7 pages of dense PDF print... Later, perhaps. I have to do some accounting chores (which I hate). And I want to have my siesta about now, too ;-) - -- Cheers, Carlos E. R. (from 12.1 x86_64 "Asparagus" at Telcontar) -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.18 (GNU/Linux) iEYEARECAAYFAlFcQXwACgkQtTMYHG2NR9Ww3gCgjrmkcHzF+wzAqjfGzJo6TgDa 8LQAoIsH330sphfaUjfjZ7vV/pi+y9fP =RZHA -----END PGP SIGNATURE-----