Hjorvik Hjorvik - 2 months ago 36
Linux Question

"Is in" condition in GAWK

I'm doing a task with Linux terminal and GAWK, and the objective is to extract a list of regular expressions and make a counter of the genes associated with this expression.

I've been able to set a GAWK expression to do this for every regular expression, but I have to run it for every expression of the list.

Is there any way to set a condition like this: If (RegExp is in RegExpList) i++1?


You can declare RegExpList as an array:

RegExpList["RegExp"] = 1;

and then use this statement:

if(c in RegExpList){do something;}

If c is RegExp, the condition will be true.

See the gawk manual for reference.