I am working on one liner book and stumbled upon
perl -pe 's/$/\n/' file
which inserts an empty line after each line, setting the end of the line to a new line, thereby adding a new line to an existing new line, resulting in an empty line. Since this is the first example without gat the end of the template, I tried
perl -pe 's/$/\n/g' file
this results in two empty lines between the lines.
I would not expect any difference, since there is only one $per line, so replacing all of them should be the same as replacing only the first.
What's going on here?
source
share