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

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -