I have a text file that looks like this:
125 126 127 { 566 567 568 569
The numbers are left justified, and the pattern is always the same in terms of enlargement and braces at the end. I need to catch only the starting number. Brackets are always found and bounded by the end of the sequence. The beginning of the file, as shown, starting with '125'.
In short, I need:
125 566 700
What I came up with:
grep -A1 '{' | grep -v '{' | grep -oE '(^[0-9]+?)'
but it omits 125 ', but I overcame by adding a new line to my head and inserting {
.
I hope to bring this into one regular expression.
Suggestions and best algorithms are welcome.
source share