Groups | Search | Server Info | Login | Register
Groups > comp.unix.misc > #441
| From | Keith Thompson <Keith.S.Thompson+u@gmail.com> |
|---|---|
| Newsgroups | comp.unix.misc |
| Subject | Re: How do you "grep" in a string when you know how it starts and how it ends? |
| Date | 2024-04-24 08:52 -0700 |
| Organization | None to speak of |
| Message-ID | <87edaun4fh.fsf@nosuchdomain.example.com> (permalink) |
| References | <v0b809$2cs3r$1@dont-email.me> |
Ottavio Caruso <ottavio2006-usenet2012@yahoo.com> writes:
> Sorry for the convoluted title, but let's say I am looking for all the
> occurrences of "keep on *ing" in a file, so that it catches:
>
> keep on running
> keep on doing
> keep on walking
>
>
> I tried:
>
> $ grep -i "keep on *ing" file
The " *" matches zero or more spaces.
> and
>
> $ grep -i "keep on [a-zA-Z0-9_]ing" file
The "[a-zA-Z0-9_]" matches exactly one character from the set, so it
will match "keep on xing".
> but it obviously didn't work.
$ grep -i "keep on [a-zA-Z0-9_]*ing" file
That will match "keep on ing". If you want to match at least one
alphanumeric before the "ing:
$ grep -E -i "keep on [a-zA-Z0-9_]+ing" file
This doesn't handle accented letters.
--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Working, but not speaking, for Medtronic
void Void(void) { Void(); } /* The recursive call of the void */
Back to comp.unix.misc | Previous | Next — Previous in thread | Next in thread | Find similar
How do you "grep" in a string when you know how it starts and how it ends? Ottavio Caruso <ottavio2006-usenet2012@yahoo.com> - 2024-04-24 16:20 +0100
Re: How do you "grep" in a string when you know how it starts and how it ends? Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2024-04-24 08:52 -0700
Re: How do you "grep" in a string when you know how it starts and how it ends? Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2024-04-24 08:58 -0700
Re: How do you "grep" in a string when you know how it starts and how it ends? Grant Taylor <gtaylor@tnetconsulting.net> - 2024-04-24 20:19 -0500
How do you "grep" in a string when you know how it starts and how i Amessyroom@f10.n1.z38.fidonet.org (Amessyroom) - 2024-07-11 23:25 +1300
csiph-web