I am parsing a log with key values spread all over in the following fashion:
TEST 1 SCHEME 12 SET EMPTY
VARLEN SET TEST 1201 PARAM1 EMTY PARAM2 SET
SCHEME 12 REFRESH TEST 8
I need to extract test number, my result should be
1
1201
8
I use awk for processing this log and use split to search for the values:
n = split($0, a);
for(i = 1; i <= n; i++) {
if(a == "TEST") {
value = a[i+1];
}
}
I suspect my code is not efficient, I thought of using index($0, "TEST") within substr etc.., but my code ended up using two index() calls and this is not the best way either.
Any ideas how to improve the code would be appreciated.