On 07.05.13 10:39, Patrick Shanahan wrote:
> * John Niendorf <j...@jfniendorf.org> [05-07-13 10:37]:
>  [...]
> > What is egrep and how does it work? (OK I guess I could look up the man 
> > page.)
> > Biggest question is: Is egrep a vim only thing or can a nano wimp use it 
> > too? ;-)
> 
> Your question will be answered when you do read the man page.

:-))

John, please don't be put off by a bit¹ of learning curve when starting
out with REs. Read also "man 7 regex", and google a bit for any intro
bumpf that is lying about. E.g. "GAWK: Effective AWK Programming" is a
pdf with a useful "Regular Expressions" section immediately following
the "Getting Started" section.

If you always have a spare xterm or two open, then it is quick to bring
one to the foreground, whack in a quick egrep invocation, and pipe
its output to "more", or redirect it to a file, e.g:

egrep -n 'line *number' /usr/local/src/vim73/runtime/doc/* > /tmp/vim

Here I had become impatient with "helpgrep" in vim taking too long to
step (via successive :cnext) to what I was hoping to find. That egrep
invocation put all matches into /tmp/vim, which I opened with vim, then
did a "gf" (go file) on the filename preceding the matching text on the
most promising line I could see. If no good, Ctrl-^ whips us back to
the egrep-generated file index, and we "gf" on the next likely
candidate. Pretty much any text in the filesystem succumbs rather
quickly to such searching.)

I do agree with "man 7 regex", which says »
Regular expressions ("RE"s), as defined in POSIX.2, come in two forms:
modern REs (roughly those of egrep; POSIX.2 calls these "extended" REs)
and obsolete REs  (roughly  those  of ed(1); POSIX.2 "basic" REs).
Obsolete REs mostly exist for backward compatibility in some old
programs; they will be discussed at the end.  
«

I've never tried the ubuntu package:

txt2regex - A Regular Expression "wizard", written with bash2 builtins

but it might be worth a look.

Incidentally, mutt essentially uses posix EREs, with GNU regex
extensions.

Erik

¹ There's a lot of merit in starting with simple expressions, with a lot
   of literal text, and becoming adventurous by degrees. (The above
   regex only adds "any number of spaces, including none" between the words.

-- 
Some [people] feel that the best way to improve Perl would be to go
back in time and shoot the author before he wrote it.
                                                       -Larry Wall

Reply via email to