How Do I Grep First Occurrence in Unix?
Contents How Do You Grep Only One Occurrence? 4 Answers Alternative Syntax: Grep -O “[^ ]*” – Kenorb Oct 16 ’15 at 15:19. @Kenorb Which Is a Bit Different...
Contents
How do you grep only one occurrence?
4 Answers
- Alternative syntax: grep -o “[^ ]*” – kenorb Oct 16 ’15 at 15:19.
- @kenorb which is a bit different actually (but will work in most cases). – peterph Oct 16 ’15 at 21:41.
- Use grep -oE … for regular expression – Morten Zilmer Jul 1 ’20 at 5:55.
Must Read
How do I get my first grep match?
6 Answers. –m 1 means return the first match in any given file. But it will still continue to search in other files. Also, if there are two or more matched in the same line, all of them will be displayed.