Parsing an input file through awk I ran into an issue with anchors in awk.
Given the following file:
2015
2015
test
test
Output with awk
$ awk '$1 ~ /^[0-9]/' file
2015
2015
Output with sed
$ sed -n '/^[0-9]/p' file
2015
Can somebody explain the behaviour I'm seeing in awk?
Seen with
- CentOS 7, GNU bash 4.2.46, GNU Awk 4.0.2
- AIX 7, GNU bash 4.3.30, awk (default version in AIX), and gawk 4.0.2