I like to convert documents to EPUB format because it is easier for me to read. However, if I do this for for example some code documentation, some really long lines of code are not readable in the EPUB, because they trail off-screen. I would like to automatically insert spaces in any words in a text file (specifically, a Pages document) over a certain length, so they are reduced to say, 10 character words, at maximum. Then, I will convert that Pages document to an EPUB.
How can I write a bash script which goes through a Pages document and inserts spaces into any word longer than, perhaps, 10 characters?
sedis your friend:For every sequence of 10 non-whitespace characters in each line, add a space after (The
&in the replacement text is itself replaced with the matched text).If you want to change the file inline instead of making a copy,
edcomes into play:(Or some versions of
sedtake an-iswitch for inline editing)