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*

8
  • In practice only the last line can miss \n so maybe it would be enough to ignore last line? Commented Jun 13, 2018 at 17:37
  • What is the best way to conditionally ignore the last line? Commented Jun 13, 2018 at 17:37
  • Instead of doing grep string FILE do head -n -1 FILE | grep 'string' Commented Jun 13, 2018 at 17:39
  • That might throw out the last line incorrectly. Commented Jun 13, 2018 at 17:40
  • Oh, ok. We can test if the last character in the file is \n. What shell do you use? Commented Jun 13, 2018 at 17:41