Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

7
  • 2
    I didn't realize the "." needs to be escaped in grep. Is it treated as a wild card? Commented Mar 13, 2018 at 15:22
  • 3
    @thebunnyrules "." in regex means one of any character. Commented Mar 13, 2018 at 16:11
  • 3
    This does not work for me on macOS with zsh. Soon as I add the $ I get no matches, when I can see without the $ that I should get a match. ^ works for beginning of the line, but $ doesn't work for EOL Commented Jan 23, 2022 at 1:44
  • 3
    @jordanm Sorry, the issue is with grep not ls. I'm doing "cat list_of_words.txt | grep '^lunar$'" Without the $ I get a list of 5 words: lunar, lunaria, lunarian, lunarians, lunars .. if I add the $ then I expected to get just "lunar" but I get nothing. Using \b instead of $ works. Commented Jan 23, 2022 at 3:18
  • 3
    @jordanm Sort of, I confirmed the problem by dumping the hex bytes with 'od -tx1a'. The line separators in that file are /r/n not /n Commented Jan 24, 2022 at 0:32