Test if the first character is a number using awk -
how check if first character of string number using awk. have tried below keep getting syntax error.
awk ' { if (substr($1,1,1) == [0-9] ) print $0 }' da.txt
i suggest use @hek2mgl solution. have pointed out of problems.
problems:
- you should use regex inside
/..regex../
. - use
~
instead of==
.
valid:
awk '{ if (substr($1,1,1) ~ /^[0-9]/ ) print $0 }' file.txt
Comments
Post a Comment