shell$ perl -pi.bak -le 's/(?<=[^n])n|n(?=[^n])/^/ig' yourfile.txt