Search code examples
unixmetacharacters

What does grep ^- mean in UNIX?


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


Solution

  • ^ 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