How to write a script to match a searched name to a given list?
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:
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.
This is what I've got so far:
It returns this result:
So it's close but this is what each of the lines looks like in full:
I have no idea why it's giving me ANNETTA since it doesn't even match ANA's value of 0.120.
I'm sorry this was heaps long, but any help would be much appreciated thank you!
Last edited by Scott; 10-17-2017 at 07:59 PM..
Reason: Please use code tags
[...]
So it's close but this is what each of the lines looks like in full:
I have no idea why it's giving me ANNETTA since it doesn't even match ANA's value of 0.120.
[...]
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!
Quote:
Originally Posted by Aia
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.
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?
Scripting language: Shell script
I want to Scan IP's from IPlist.txt through Nessus using shell scripting language. Give the Input (IPlist) to nessus and generate Nessus report in xml or PDF form which is saved automatically on computer .
Please help if any one has idea about how to write... (2 Replies)
The below bash connects to a site, downloads a file, searches that file based of user input - could be multiple (all that seems to work). What I am not able to figure out is how to display on the screen match found or no match found" and write a file to a directory (C:\Users\cmccabe\Desktop\wget)... (4 Replies)
the following pattern match works correctly for me
awk '/name="Fruits"/{f=1;next} /"name=Vegetables"/{f=0} f' filename
This works well for me. Id like to temporarily move the match out of the file ( > newfile) and be able to stick it back in the same place at a later time.
Is this... (7 Replies)
I need to parse a file and depending on a patern match(in the insert job line) separate files have to be created with a line added (content in file2).
Mapping for pattern match and add line :
for Alpha 123
for Beta 234
for Gamma 345
no match (goes into another file)
File 1 ... (3 Replies)
Hi all
I have another question as of now.
I have two files
One file contain
data like this
Serendipity
glamerus
Shenpurity
In another file these entries are present in different columns like this from 2 column onwards
SRN Serendipity Non serendipity ... (1 Reply)
Hi Friends,
I'm a great fan of this forum... it has helped me tone my skills in shell scripting. I have a challenge here, which I'm sure you guys would help me in achieving...
File A has a list of job ids and I need to compare this with the File B (*.log) and File C (extend *.log) and copy... (6 Replies)
Hi all,
I have 2 files:Column1 of first file has to be matched with column 3 of second file
first file contain DATA like this in 2 columns one with gene name second with whether CAD,HT,RA T2Dor any one
column 1 column2
ARFGEF2 CAD
DDEF2 CAD
PSCD3 CAD
PSCD4 CAD
CAMK1... (5 Replies)
Hello,
I'm taking a username from keyboard as input and i want to check if it exists in a list under a directory for example "/home/students/" ....
if there is a match i want to type the list...
can anyone give me an example or a tutorial to read plz?
thnx for your help. (1 Reply)
Hi all
I have two files X.txt and Y.txt. Both file contains same number of sentences. The content of X.txt is
The filter described above may be combined.
and the content of Y.txt is
The filter describ+ed above may be combin+ed.
Some of the words are separated with "+"... (2 Replies)
hi
i want to write a script that contain questions upto 50..when i run the script it has to ask the questions one by one with options like a,b,c,d and user has to answer the each question and finally result (contain how many user selected correctly)
please help me...i need hints to do....... (8 Replies)