I am copying text from a pdf, and when I paste it into a text editor it comes out like this:The text does not extend to the right margin but looks like a column, and there's a space between the lines. I'd like the text to extend to the right margin and no spaces between lines. I can format this manually, but it's very time consuming. Is there a program which will allow me to automate this?
Format Text With Spaces Between Lines
text formatting
grep . removes all blank lines. You can pipe the result into fmt to reformat the text to a width of your choice. If you have the text in the X clipboard, xsel -b will get it from there.xsel -b | grep . | fmt -w 80 >reformatted.txtIf you don't want line breaks at all, you can replace newlines by spaces, but add a newline at the end.xsel -b | grep . | tr '\n' ' '; echoThe output won't be very good, because according to your image, hyphens are lost, so vul-/gar comes out as vul gar, Thanks-/giving as Thanksgiving, etc.grep . collapses all paragraphs into one. You can avoid this only if there is some way in which paragraphs are marked in your text. If there is a single blank lines between lines of the same paragraph and at least two blank lines between paragraph, you can remove line breaks and preserve paragraph breaks like this:awk 'length {if (previous < NR-2) print ; previous = NR; print}'You can try running pdftotext on the PDF directly. This won't reformat the text and may or may not include the blank lines (it depends how the PDF was made).