Hi all,
One small doubt, reg exp in awk, is it possible to extract the match of regular expression like in perl?
eg:
B R16288 Map3_NoCat
B R16067 Map4_NoCat
B R16647 Map3_NoCat
B R16450 Map3_NoCat
B R16106 Map6_NoCat
B R16000 Map3_NoCat
B R16395 Map3_NoCat
B R16243 Map3_NoCat
B R16023 Map12_NoCat
B R16421 Map3_NoCat
if I wanna extract the digits after Map, in perl I could say
you r deleting the 'map', but what i want is to store the digits after map in order to do some logical test (say if the digit is > 5 then print the whole line)
No, in traditional awk you can't do that, as awk doesn't support back references. If you use Gnu awk (gawk), you could use the gensub()-function, which supports back references. If you don't have gawk, use sed instead.
Yes, since that was what you asked for - if you have additional requests, please let it not sound as if there was missing someting in the answer to the original question, ty
awk -F"[ _]" '{a=$0; sub(/Map/,"",$3); if($3 > 5) print a}' infile
B R16106 Map6_NoCat
B R16023 Map12_NoCat