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

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

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