Full title: How to write a script to match a searched name to a given list, and then returns other names with the same properties
Anyway, first time here, hi! So I'm taking an introductory course at uni and there's a question in our lab that asks us to write a script where a user can search a name which will then be compared to a given list of names where each line looks like this:
ANA,0.120,55.989,181
The script has to then look at the frequency associated with that name (second column, so in ANA's case, 0.120) then output a list of names which match that frequency and sort it in alphabetical order.
A . (period) will match any character except a new line by default when used as a regex.
The variable $freq will contain the expression 0.120 A character zero, followed by any character except a new line, followed by the character one, followed by the character two, followed by character zero.
grep is matching that in the ANNETTA line if you notice what I have highlighted in red.
Ohhh I see why it's matching to Annetta now .. thanks Aia!
I'm not sure I understand ... If I specify a regular expression in the frequency variable, will the script still work if I searched for a name with a different frequency number? Like say if I searched Annetta which has 0.006.. shouldn't I give the script freedom so it can find other names with a frequency of 0.006?