How to recognize tab space in my search string while using awk?

My input file is .h file containing

#define __CON__       2
#define __CON_MINOR__ 23

#define __CON_PREREQ(maj, min) \
        ((__CON__ << 16) + __CON_MINOR__ >= ((maj) << 16) + (min))

I need to search for __CON_ which prints out 2 and 23 as 2.23. There's a tab space after CON__. I'm using the command

awk '/__CON__/&&'/__CON_MINOR/' {print $3;}' features.h

getting a wrong output for this.

linuxbashawk

Answers

answered 1 week ago Robert Baldyga #1

You can do something like this:

awk '/__CON__/ {con=$3;} /__CON_MINOR__/ {print con "." $3; exit;}' features.h

comments powered by Disqus