Issue
I am relatively new to grep and unix. I am trying to get the names of people who have won more than 50 races from a txt file. So far the code I have used is, cat file.txt|grep -E "[5-9][0-9]$"
but this is only giving me numbers from 50-99. How could I get it from 50-200. Thank you!!
driver | races | wins |
---|---|---|
Some_Man | 90 | 160 |
Some_Man | 10 | 80 |
the above is similar to the format of the data, although it is not tabulated.
Solution
Do you have to use grep? you could use awk like this:
awk '{if($[replace with the field number]>50)print$2}' < file.txt
assuming your fields are delimited by spaces, otherwise you could use -F flag to specify delimiter.
if you must use grep, then it's regular expression like you did. to make it 50 to 200 you will do:
cat file.txt|grep -E "(\b[5-9][0-9]|\b1[0-9][0-9])$"
Answered By - urirot