B
B
bychok3002017-09-26 22:53:54
linux
bychok300, 2017-09-26 22:53:54

How to write grep regex correctly?

There is a set of such strings, how to find a number that starts after a comma, has a length of more than 2 characters and starts with numbers from 5 to 9, that is, 54 or 643 or 556 or 6777
38499.2
38501.3
38502.5
38504.4
38505 ,4
38506.2
38508.1
38509.2
38510.4
38511.5
38512.5
as soon as I tried it, it doesn't work, for example: grep -F '*([5-9]|[0-9]| [0-9])$'
grep -E ',*([5-9]|[1-9]|[1-9])$'

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
DevMan, 2017-09-26
@bychok300

grep -E ',[5-9]\d+$'
https://regex101.com/r/0IZyYh/1

S
Saboteur, 2017-09-27
@saboteur_kiev

Since there is no "at the end of the line" in the condition, it would be more correct without $ at the end
grep -E ',[5-9]\d+'

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question