Issue
I'm trying to compress a text document by deleting of duplicated empty lines, with sed
. This is what I'm doing (to no avail):
sed -i -E 's/\n{3,}/\n/g' file.txt
I understand that it's not correct, according to this manual, but I can't figure out how to do it correctly. Thanks.
Solution
As tripleee suggested above, I'm using Perl instead of sed
:
perl -0777pi -e 's/\n{3,}/\n\n/g'
Answered By - yegor256 Answer Checked By - Robin (WPSolving Admin)