On Thu 2003-02-06 at 14:56:31 -0900, [EMAIL PROTECTED] wrote: > On Thursday 06 February 2003 01:55 pm, FemmeFatale wrote: [...] > > Thx CM. Question: what are regular expressions ? And sed? Heard of > > it... but no clue what it is... I'll look it up later. The "regular > > expressions" has me stumped though mostly. [...] > A regular expression is something like > ^[K][k].*retry\ [[:lower:]] > > Which would match lines starting with K or k and have "retry" followed by a > space and lowercase characters
Not completly correct ;) That would be
^[kK].*retry\ [[:lower:]]
The one you wrote expects Kk (sic) at the start.
Aside from that, your example looks complex for starters. IMHO, the
nice thing about regular expressions is that you can start slowly,
some examples (read man regexp for more, it's really not so hard, if
you are concentrating on what you need).
hello that's a valid regular expression, simply for "hello"
^hello now "hello" has to be the start of the line
h[ae]llo this may be "hallo" or "hello"
h.llo "." matches any character: "hallo", "hbllo", "hcllo", ...
hal*o "*" means "any times": "hao", "halo", "hallo", "halllo", ...
So ".*" means "any charachter, as often as you want"
> It allows for REALLY advanced searches and works well with grep
> egrep rgrep etc.
That would look like
grep '^[hH]' somefile
which will search for all lines starting with a "h" in somefile.
Everyone, try it out now! :-)
Regular expressions are a mightly tool. It's like vi, everyone should
know the basics. ;-)
HTH,
Benjamin, now goes trolling elsewhere.
PS: I know, that one could use
grep -i '^h'
instead, but no need to get my example more complicated. Figuring
out why this does the same is left as exercise to the reader. ;)
msg118489/pgp00000.pgp
Description: PGP signature
