File indexing completed on 2024-05-12 04:02:10

0001 #!/usr
0002 # AWK hl test
0003 
0004 # BEGIN and END are also matched as patterns
0005 BEGIN {
0006   p = 0;
0007 }
0008 
0009 /some pattern/ {
0010   p++;
0011 }
0012 
0013 # / inside brackets is not considered end of expression
0014 # a loose division operator (/) is not mismatched as a pattern.
0015 $1 =~ /[^abc/]def/ || b == 3 / 5 {
0016 
0017   gsub ( FILENAME );
0018 
0019 }
0020 
0021 # TODO and FIXME also work in comments in Awk.
0022 
0023 # Also backslash in patterns works.
0024 /\/usr\/bin\/awk/ { print "This is me"; }
0025 
0026 END {
0027   print p;
0028 }
0029 
0030 function myfunc()
0031 {
0032     print 42
0033 }
0034 
0035 /abc/,/a[b]c/{
0036   # parameter with a regex
0037   if (match($0, /a/)) {}
0038 
0039   "x\ax\nx\ex\zx\023x\2x\xffx\xFf\xax\12x"
0040 
0041   a =~ /[[:alpha:]]/
0042   a =~ /[xx[:alpha:]xx]/
0043   a =~ /[a-z[:alpha:]xx-]/
0044   a =~ /[]a]/
0045   a =~ /[-a]/
0046   a =~ /[^]a]/
0047   a =~ /[^-a]/
0048   a =~ /[a]a\/\n/
0049   # incomplete regex
0050   a =~ /[xx[:alph
0051   a = 23.2
0052 }