What does grep ^- mean in UNIX?

2.9k views Asked by At

As title says, what does grep ^- mean in UNIX? I know what grep is but not the metacharater ^- part.

3

There are 3 answers

0
Paul Creasey On BEST ANSWER

^ is the regular expression meta character for start of line - in this context is not a metacharacter

This expression therefore matches any - character at the start of a line and with grep will return any line starting with -

will match

-Hello world

Won't match

Hello - world
0
andrux On

It means to search for a string starting with the hyphen character.

The ^ character matches the beginning of the string

0
Arnkrishn On

It matches the beginning of a line or string. Please check the list of meta characters supported by different Linux programs here - http://docstore.mik.ua/orelly/linux/lnut/ch09_02.htm

Hope this helps.