awk to update specific value in file with match and add +1 to specific digit
I am trying to use awk to match the NM_ in file with $1 of id which is tab-delimited. The NM_ will always be in the line of file that starts with > and be after the second _. When there is a match between each NM_ and id, then the value of $2 in id is substituted or used to update the NM_. Each NM_ may not be unique, as in the example below, but will have a match in id.
After the third _ there is a digit 0,1,2,etc that I am trying to add the word exon and add +1 to the digit. Not sure if my awk attempt helps at all to address the first question. Thank you .
file
id
desired output value in bold updated with $2 in id because NM_ matched in $1 of id,
value in italics added one to the 0 and the word exon
awk
Last edited by cmccabe; 12-17-2016 at 11:33 PM..
Reason: fixed format, added details, fixed typo
Could you please try following and let me know if this helps.
Output will be as follows. EDIT: Just going through your output again, not sure how the last 2 rows got the replacement in your output? As I can't see like string NM_001195683, my code is not taking care of this as I am not sure how it has come over there, kindly explain it more so that we could try to help you on same.
EDIT2: Adding a non-one liner form of solution now too.
Thanks,
R. Singh
Last edited by RavinderSingh13; 12-17-2016 at 03:39 AM..
Reason: Added a comment now to ask OP a question about OP's output which is not clear.
This User Gave Thanks to RavinderSingh13 For This Post:
File2 is tab-delimeted and I am trying to use $2 in file1 (space delimeted) as a search term in file2. If it is found then the AF= in and the FDP= values from file2 are extracted and printed next to the file1 line. I commented the awk before I added the lines in bold the current output resulted. I... (7 Replies)
I have been reading old posts and trying to come up with a solution for the below: Use a tab-delimited input file to assign
point to variables that are used to update a specific field, Rank. I really couldn't find too much in the way of assigning points
to variable, but made an attempt at an awk... (4 Replies)
I am trying to create a cronjob that will run on startup that will look at a list.txt file to see if there is a later version of a database using database.txt as the source. The matching lines are written to output.
$1 in database.txt will be in list.txt as a partial match. $2 of database.txt... (2 Replies)
In the below awk I am trying output to one file those lines that match between $2,$3,$4 of file1 and file2 with the count in (). I am also trying to output those lines that are missing between $2,$3,$4 of file1 and file2 with the count of in () each. Both input files are tab-delimited, but the... (7 Replies)
Trying to combine strings that are a partial match to another in $1 (usually below it). If a match is found than the $2 value is added to the $2 value of the match and the $3 value is added to the $3 value of the match. I am not sure how to do this and need some expert help. Thank you :).
file
... (2 Replies)
I am trying to add a tab after the last digit in $3 in the input. The grep below is all I can think off. Thank you :)
sed -n 's/:/&/p' input
input
chr1 955542 955763AGRN-6|gc=75
chr1 957570 957852AGRN-7|gc=61.2
chr1 976034 976270AGRN-9|gc=74.5
desired output
chr1... (5 Replies)
Dear All,
Lets say I have a number with following format:
####.12e-##
now I want to compare place holder in position 1 and 2.
How can I do that?
Note: My number is stored in a variable say var.
example:
var=9999.12e-05
Thanks & Regards,
linuxUser_ (6 Replies)
I'm trying to update a text file via sed/awk, after a lot of searching I still can't find a code snippet that I can get to work.
Brief overview:
I have user input a line to a variable, I then find a specific value in this line 10th field in this case. After asking for new input and doing some... (14 Replies)
Hi,
I have the following text file:
8 T1mapping_flip02 ok 128 108 30 1 665000-000008-000001.dcm
9 T1mapping_flip05 ok 128 108 30 1 665000-000009-000001.dcm
10 T1mapping_flip10 ok 128 108 30 1 665000-000010-000001.dcm
11 T1mapping_flip15 ok 128 108 30... (2 Replies)
Hi,
I am having trouble converting a text file. I have been working for this whole day now, still i couldn't make it.
Here is how the text file looks:
_______________________________________________________
DEVICE STATUS INFORMATION FOR LOCATION 1:
OPER STATES: Disabled E:Enabled ... (5 Replies)