Menu

quine in awk

2011-09-09

Quines are self-printing programs. Here’s one for fun in awk (gnu awk).

source

quine_gawk.awk

BEGIN{S="BEGIN{S=\"%s\";s=S;gsub(/\\\\/,\"\\\\\\\\\",s);gsub(/\\\"/,\"\\\\\\\"\",s);printf(S,s)}";s=S;gsub(/\\/,"\\\\",s);gsub(/\"/,"\\\"",s);printf(S,s)}

usage

awk -f quine_gawk.awk 2>/dev/null | diff quine_gawk.awk -

Related tags:


site menu

Back to top