0
votes

I have a text file which some of the entries look like this:

"Hello, my name is

George. Its very nice to meet you"

and I would like to run an SED or AWK command that gives me the following result:

"Hello, my name is George. Its very nice to meet you"

I know I can remove blank lines with SED by running:

sed '/^\s*$/d' 

That command only removes the blank line but it does not join the string as shown above.

Thanks

2
can you paste more content of your file? - Kent

2 Answers

2
votes

I would use awk:

awk 'BEGIN{RS="\n\n";ORS=" "}1' file

The command is using two newlines (a blank line) as the input separator and a space as the output record separator.

1 is an awk idiom. It will always evaluate to true which makes awk print every record.


Btw, if your blank lines may contain whitespace, change the command to:

awk 'BEGIN{RS="\n[[:space:]]*\n";ORS=" "}1' file
0
votes

Go menu -> Edit -> Line operations - Choose "Remove Empty Lines" in Notepad ++

in one click all extra lines get removed :)