Using awk, how I do specify doing something only when the first field is an integer? -


i starting out in awk, , wonder, using awk, proper way state, (such printing out record) when first field integer?

do ... when first field integer?

this command in braces, print in case, if first field positive integer:

awk '$1 ~ /^[[:digit:]]+$/{print;}' 

floating point numbers rejected.

if want accept either positive or negative integers, then, mklement0 suggests, use following:

 awk '$1 ~ /^[+-]?[[:digit:]]+$/{print;}' 

note that, because [:digit:] used, these tests unicode safe.


Popular posts from this blog

javascript - Js, document.getElementById("ID").innerHTML, error -

objective c - Is there a way in OCMockito to make stubs fail when an unknown method is called? -

jquery - jqGrid update specific column data with out refreshing the entire column? -