How to tell awk not to parse a string in a variable assignment with -v
option:
$ awk -v s='\n' 'BEGIN {print "[" s "]"}'
[
]
it does not parse in the following
$ echo '\n' | awk '{print "[" $0 "]"}'
[\n]
$ awk 'BEGIN {print "[" ARGV[1] "]"}' '\n'
[\n]
$ s='\n' awk 'BEGIN {print "[" ENVIRON["s"] "]"}'
[\n]
And parses in the following
$ awk 'BEGIN {s = "\n"; print index(s, "n"), index(s, "\n")}'
0 1