0

I'm just searching in emacs some strings with following pattern:

^*DEFUN*event*$

So i've used grep:

grep -nR "^*DEFUN*event*$" *

but got no match, instead there's a lot of them for example:

DEFUN ("internal-event-symbol-parse-modifiers", Fevent_symbol_parse_modifiers,

What's wrong?

AdminBee
  • 22,803

1 Answers1

2

You are using globbing characters (aka "wildcards") where grep is expecting a regular expression. However, in regular expressions, the * does not mean "any sequence of characters", but "zero or more of the previous character". When it is used as the first character of an expression (or immediately after the "start-of-line" symbol ^), it stands for a literal asterisk.

So, your expression ^*DEFUN*event*$ searches for lines that

  • start with an *
  • immediately continue with DEFU
  • followed by zero or more N
  • followed by the word even
  • and continuing with zero or more t up to the end of the line.

The regular expression you are looking for would be

^.*DEFUN.*event.*$

or in short (as also mentioned by Stéphane Chazelas in a comment)

DEFUN.*event
AdminBee
  • 22,803