LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Using JOE as a word processor (https://www.linuxquestions.org/questions/linux-software-2/using-joe-as-a-word-processor-302693/)

erraticassassin 03-17-2005 07:27 AM

Using JOE as a word processor
 
Hi all,

I have an old laptop which is rather slow. At the moment I'm using JOE as a word processing - I find I can be very productive with JOE, as it's very quick to run, even on my 233Mhz lump, and it doesn't offer lots of distracting buttons to press... :)

JOE doesn't offer any kind of formatting, so I'd like to be able to use OpenOffice Writer on my main PC to tidy up the plain text files after I've finished with them on my laptop. However... opening a document written in JOE in OOoW reveals that JOE sticks a carriage return at the end of every line, instead of just the end of a paragraph, which would make reformatting a long document a bit of a pain.

The JOE man pages mention a command line option for altering the use of carriage returns and line feeds; I've also read elsewhere about using a command line option to re-encode a plain text file to Unix/DOS/Windows format.

It all seems rather confusing! Can anyone shed any light on the various encoding schemes?

Nobber 03-17-2005 10:13 AM

If I understand correctly, you want to replace mid-paragraph newlines with a space. If the text you want to process is in the file test.txt, try this at a bash prompt:
Code:

while read line; do [ -z "$line" ] && (echo; echo) || echo -n "$line "; done < test.txt > output.txt
and then have a look at the contents of output.txt. I tried this on a very simple input file and it seemed to do what you're after.

erraticassassin 03-18-2005 02:17 AM

Thanks Nobber, that's spot on! The next step will be to fiddle around a bit and see if I can create an alias, so I don't have to type a string of gobbledigook every time... :)

Ta very much!

Nobber 03-19-2005 05:31 AM

Better than an alias would be a script:

Code:

#!/bin/sh
while read line; do
  [ -z "$line" ] && (echo; echo) || echo -n "$line "
done < $1 > ${2:-output.txt}

Save that in a file called "myscript" (for example) and make it executable (chmod 755 myscript). Then to process the file "test.txt" and shove the output into "test2.txt", do:

Code:

./myscript test.txt test2.txt
(If you don't give an output file name, the script will default to using "output.txt".)

erraticassassin 03-19-2005 02:53 PM

Even better! All I have to do now is come up with a name for the script... like Milford Cubicle...


* Later....

Hmmm... I pasted the above text into a new document, made it executable, and tried it out. No go. I'm not at a Linux box at the moment, so I can't confirm what the error message was...


All times are GMT -5. The time now is 01:27 PM.