In perl
perl -n00Elp00e 'chomp;s's/\n/ /g;say'g' your_file
Explanation
l: Remove the input record separator from the current record being processed and add the current output record separator (a newline by default) after each printed line.-np: Operate on the file record by record and print the current record after processing.-00: Means the record separator is two or more consecutive newlines-Ee: execute the following string as code while setting the default variable ($_) to the record currently being read from the file.chomp: remove the record separator from$_s/\n/ /g: Replace every newline encountered in the current record with a space (thegmodifier ensures the replacement is "global").say: Prints the contents of$_with a newline added at the end. It is used here instead ofprintbecausechompwill have removed the newlines separating the different paragraphs. It is equivalent toprint "$_\n".- We needed to use
-Erather than-ebecause it enables the use of more recent language features; thesayfunction in this case.