Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Transforming txt file before etiting in the wordprocessor (solved)

14 views
Skip to first unread message

zakend

unread,
Mar 21, 2013, 5:02:10 AM3/21/13
to
We have rather big text file. Any line is ended with the EOL.
We need to edit it in Libreoffice with sensible praragraphs.

The script has to:

1. input new line after [.\n] on the end of line,
2. input new line after [?\n] on the end of line,
3. input new line after [!\n] on the end of line,
3. change [,\n] for [space] on the end of line,
4. change [-\n] for [space] on the end of line if there is no [space] before [-]
5. change [\n] for [space] on the end of line if there is no next [\n] after [\n]

After help I have in this list the final script will be

#v+

#!/usr/bin/awk -f
#from https://groups.google.com/forum/?hl=pl&fromgroups=#!topic/comp.lang.awk/1SiyHFrILLU

FNR<=40 { print } # FNR lines without changed them
FNR>=41 { l = l != "" ? l" "$0 : $0 } # FNR lines wchich will change
/^.*[.?!]$/ { print l"\n"; l = "" } # transformation of text
END { print l } # printing output efect of changed lines

#v-

Thanks for help and chance to learn to all posting in previous posts.
I hope this will save time to many lamers who try to transform ebook.pdf to ebook.epub ;)

zak
0 new messages