Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.unix.misc > #441
| Path | csiph.com!news.swapon.de!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail |
|---|---|
| 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 | Wed, 24 Apr 2024 08:52:50 -0700 |
| Organization | None to speak of |
| Lines | 37 |
| Message-ID | <87edaun4fh.fsf@nosuchdomain.example.com> (permalink) |
| References | <v0b809$2cs3r$1@dont-email.me> |
| MIME-Version | 1.0 |
| Content-Type | text/plain |
| Injection-Date | Wed, 24 Apr 2024 17:52:50 +0200 (CEST) |
| Injection-Info | dont-email.me; posting-host="8912a4ab33884690e874a0120806b9cc"; logging-data="2534126"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+5qRl6pVqbEN2SvQv/j1M9" |
| User-Agent | Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) |
| Cancel-Lock | sha1:h4sM+MoMbejKi26Elvw5+fBAgtM= sha1:LQb740iwEpfTudxipc8Tk6RC+ew= |
| Xref | csiph.com comp.unix.misc:441 |
Show key headers only | View raw
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