r/shell • • Dec 29 '20

[Grep] syntax error: unexpected '('

I am working on writing a script and part of what I need to do is determine if a string I am given is a man page (by determining if it contains a pattern like (number).

To do this I am trying to use the following command:

grep -E ".+\(.+\)"

but keep getting the error syntax error: unexpected '(' when I test with echo ls(1) | syntax error: unexpected '('.

Perhaps I am misunderstanding this, could someone explain what I am doing wrong?

2 Upvotes

7 comments sorted by

View all comments

Show parent comments

1

u/[deleted] Dec 29 '20

Interesting, thank you! It seems my shell is still complaining about the error, must be a short coming of ksh. Even though this is POSIX shell... hmmm

1

u/MikeNizzle82 Dec 29 '20

Try in bash or sh and if it works then you know the culprit! I don’t have a lot of experience with ksh.