1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
#!/bin/awk -f BEGIN { n_exports = 0; } { if ($0 ~ /^exports.*=/) { exports[n_exports] = substr($3, 0, length($3) - 1); n_exports++; } else { print; } } END { for (i = 0; i < n_exports; i++) { print "this." exports[i] " = " exports[i] ";"; } }