Reputation: 175
I'm trying to write a grep command that will match a python function declaration, in the form
def hello(hello)
so def, one space, a word that starts with either a letter, number or an underscore, open parenthesis, another word, closed parenthesis. I'm using the command
grep ^"def "[/-a-zA-z0-9][a-zA-z0-0]*[/(][a-zA-z0-9]*[/)]$
but I get a syntax error saying unrelated token near ( . I cant figure out what i'm doing wrong. any ideas?
Upvotes: 0
Views: 121
Reputation: 10423
I think there are a couple of mistakes. Here is what should work:
grep '^def [_a-zA-Z0-9][a-zA-Z0-9 ]*[\(][a-zA-Z0-9 ][a-zA-Z0-9 ]*[\)]$'
Upvotes: 1
Reputation: 272802
I think you want backslashes instead of forward slashes.
Upvotes: 1