now I want to use awk to print the following lines (please see the condition below)
but only, if this line
meets the condition, that Identities should be >50 (so I am only interesting in the part Identities = 99)
This is my command for printing the second line (it is always the 5th line below the line with Identities):
the first line in the example output should only be printed, if the condition is met.
I am also able to print the first line only, without a condition:
but now my idea is to combine these to commands, so that the first line and the second line is only printed if the condition is met. I thought of putting the first line into a variable inside awk, and if the condition is met, print this first line and the second line.
I could come up with this:
but it does not work as planned.
Any help is appreciated!
Defining a variable (q) in one awk script and using that variable in a different awk script can't work. But, you can easily combine your code into a single awk script:
and get what I think you want:
You might also consider trying:
which also produces the same output. It is a little be longer, but I find it easier to read and understand.
P.S. Note that your specification said > 50, but your code used >=50. I copied the >= when I combined your code, but I used what you specified in your description in the code I wrote.
Last edited by Don Cragun; 06-03-2017 at 04:29 PM..
Reason: Add PS.
In the awk below I am trying to match the value in $4 of file1 with the split value from $4 in file2. I store the value of $4 in file1 in A and the split value (using the _ for the split) in array. I then strore the value in $2 as min, the value in $3 as max, and the value in $1 as chr.
If A is... (6 Replies)
Hello,
I am looking for a specific situation in a text file. The conditions are,
> <CompoundName>
InChI=1S/C5H12NO2/c1-5(2)4-8-6(3)7/h5H,4H2,1-3H3/q+1
I am looking for cases where the line "> <CompoundName>" is followed by a line that contains the string "InChI=" without regard to... (5 Replies)
In the file1 below if $9 and $12 are . (dot) then the value in $8 of file1 is used as a key (exact match) to lookup in each $2 of file2, when a match is found then the value of $4
in file1 is used to look for a range match within +/- 50 using the values in $4 and after in file2. The number of... (9 Replies)
In the below I can not seem to add a line that will add Not low if the statement in bold is not true or meet. I guess when the first if statement is true/meet then print low, otherwise print Not low in $(NF + 1). I am not sure how to correctly add this. Thank you :).
if(low <= $2 && $2 <=... (5 Replies)
Hi All,
Seeking for your assistance to get the records once the $2 met the condition.
Ex. file 1.txt
123455,10-Aug-2020 07:33:37 AM,2335235,1323534,12343
123232,11-Aug-2015 08:33:37 PM,4234324,1321432,34364
Output:
123455,10-Aug-2020 07:33:37 AM,2335235,1323534,12343
What i did... (5 Replies)
Hi All,
Seeking for your assistance to print all the specific field when the condition met.
Ex:
file1.txt
1|203|3|31243|5341|6452|623|22|00|01
3|45345|123214|6534|3423|6565|643|343|232|10
if field 1 = 1 and field 3 = 3 and field 5 = 5341 and field 6 = 6452
it will print from $1 to $10.... (2 Replies)
I want to abort script if input variable matched first field in any line of a file.
#!/bin/sh
read INPUTVAR1
awk "{if(\$INPUTVAR1 == $1) x = 1} END {if(x==1) print \"I want to abort script here\"; else print \"OK\"}" /etc/some.conf
I tried "exit" and system("exit") but no luck. (1 Reply)
All,
I wrote the following section of code (which logically in PHP would of worked):
tmpPATH=${1}
tmpTAG=${2}
if
then
while read tmpTAG tmpPATH
do
fi
echo $tmpTAG
echo $tmpPATH
if
then
done < ./config.cfg
fi (4 Replies)
Hello all, I created the below script....and it seemed to be working fine. My problem is i want the script to ignore rest of the things if my condition is not met but do not exit....
#!/bin/ksh
###########################
###########################
# Set name of the listener, this... (2 Replies)
Hi,
I am trying to update the 1st column of a file but only if it contains a char
here is an example of my file
1111aaa 9999 textaaa
22222bbb 9999 textbbb
3333 9999 textccc
444ddd 9999 textddd
i would like the output to remove any characters () from... (5 Replies)