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.

Required fields*

9
  • maybe the example you presented has no EOL characters Commented Jul 22, 2022 at 16:54
  • @jsotola, and how would grep decide how to print the lines then Commented Jul 22, 2022 at 16:57
  • 1
    @mark, I don't think you can do that with grep. It implicitly considers only the part of the line before the newline, and doesn't try to match the regex pattern against it. So it never matches, there's no question about it, so no reason to show it. (And, well, grep would print the trailing newline even if it isn't there, e.g. printf 'foo' |grep . prints foo<newline> in all systems I have.) Commented Jul 22, 2022 at 17:01
  • Won't it be simple enough to pipe the output of grep to cat -A? Commented Jul 22, 2022 at 17:04
  • @unxnut And then pipe to sed 's/\$$/\\n/' di differentiate a EOL $ from other instances. Commented Jul 22, 2022 at 17:09