Those who know me know that I don’t like Perl. Sometimes in life the thing you don’t like could be best tool/friend.
I need to remove a newline character from a text file: layouts/partials/pagination.html.
$ git diff layouts/partials/pagination.html
diff --git a/layouts/partials/pagination.html b/layouts/partials/pagination.html
index 00c1124..d8dd981 100644
--- a/layouts/partials/pagination.html
+++ b/layouts/partials/pagination.html
@@ -15,4 +15,4 @@
</span>
{{ end }}
{{ end }}
-</nav>
\ No newline at end of file
+</nav>
The easiest way to do this is to run the following command:
$ perl -pi -e 'chomp if eof' layouts/partials/pagination.html
Thanks Perl and this Stack Overflow question.