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*

3
  • 2
    Thanks @nezabudka, that's correct. However, I've just realized that my desired output was wrong. I've updated it. Any idea how to remove the 1st line using -v ? Commented Oct 9, 2020 at 6:07
  • 1
    If I'm not wrong, \S will need to match a character, which means that the second expression won't return lines where the spaces are located at the extreme start or end of the line. Commented Oct 9, 2020 at 6:51
  • 1
    @Kuslananda, Thanks. Of course, only for the specific case from the given example. Otherwise it should look like this: grep -E '(^|\S)\s{1,3}(\S|$)' Commented Oct 9, 2020 at 17:09