From: "Andreas Kusalananda Kähäri" <andreas.kahari@abc.se>
To: Bart Schaefer <schaefer@brasslantern.com>
Cc: Zsh-Users List <zsh-users@zsh.org>
Subject: Re: zsh-ify a bash script
Date: Thu, 20 Jan 2022 23:13:45 +0100 [thread overview]
Message-ID: <YenemY6VohA8MjDe@box> (raw)
In-Reply-To: <CAH+w=7bGXNfvQgrW6WiceX_rxV+bE5mBQJMv+8n4NqV0R-TEsg@mail.gmail.com>
On Thu, Jan 20, 2022 at 10:31:21AM -0800, Bart Schaefer wrote:
> On Thu, Jan 20, 2022 at 3:26 AM Andreas Kusalananda Kähäri
> <andreas.kahari@abc.se> wrote:
> >
> > grep -Fwo -e zsfree -e zerr -e subst -- Src/**/*.c |
>
> I think "grep -w" doesn't work for the original problem because of the
> ".*SOCK_STREAM" in one of the search terms.
Sorry for going off-topic... but...
The -w option is just a convenience thing to not have to insert one of
\b, \< \>, or [[:<:]] [[:>:]] at either end of the pattern.
Removing the -F is what needs to be done for the patterns to be treated
as BREs.
Compare
man zsh | grep -w 'as\>.*\<an'
(2 lines of output, each of which has the word "as" followed by the word
"an"),
man zsh | grep -w 'as.*an'
(7 lines of output, since "an" may match at start of word and "an" at
the end, as on a line with "as ... than"), and
man zsh | grep 'as.*an'
(15 lines of output due to matching things like "basename ... command")
What the OP may want to do is to change their expression
socketpair.*SOCK_STREAM
into
socketpair\>.*\<SOCK_STREAM
and then use -w with grep, depending on what it is they want to actually
match, and what word boundary pattern(s) their regular expression
libraries support.
--
Andreas (Kusalananda) Kähäri
SciLifeLab, NBIS, ICM
Uppsala University, Sweden
.
next prev parent reply other threads:[~2022-01-20 22:14 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-19 20:56 zzapper
2022-01-20 4:12 ` Bart Schaefer
2022-01-20 10:31 ` Mikael Magnusson
2022-01-20 10:40 ` Mikael Magnusson
2022-01-20 11:26 ` Andreas Kusalananda Kähäri
2022-01-20 18:31 ` Bart Schaefer
2022-01-20 22:13 ` Andreas Kusalananda Kähäri [this message]
2022-01-21 7:48 ` Daniel Shahaf
2022-01-21 8:50 ` zzapper
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=YenemY6VohA8MjDe@box \
--to=andreas.kahari@abc.se \
--cc=schaefer@brasslantern.com \
--cc=zsh-users@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).