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:

  1. you should use regex inside /..regex../.
  2. use ~ instead of ==.

valid:

awk '{ if (substr($1,1,1) ~ /^[0-9]/ ) print $0 }' file.txt 

Comments

Popular posts from this blog

apache - setting document root in antoher partition on ubuntu -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -

Process 'command 'F:\android-sdk\build-tools\21.1.2\aapt.exe'' finished with non-zero exit value 1 -