How do I check if the first character of a string is a number using awk. I have tried below but i keep getting syntax error.
awk ' { if (substr($1,1,1) == [0-9] ) print $0 }' da.txt
I will suggest to use @hek2mgl solution. I have pointed out some of the problems.
Problems:
/..regex../
.~
instead of ==
.Valid:
awk '{ if (substr($1,1,1) ~ /^[0-9]/ ) print $0 }' file.txt
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With