
linebreak.awk v1.0

It is the awk program to split long lines in text to shorter. Its formats:


awk -f linebreak.awk [file_name | -] start_position max_line_length
awk -f linebreak.awk help
awk -f linebreak.awk version

Default values of line length are 68 and 80.

(c)2024, Vartiklis, Jonas Skendelis. The linebreak.awk is distributed 
under MIT License (see license.txt file) allowing to use, copy, modify, 
merge, publish, distribute, sublicense, and/or sell its copies. 
Its copyright notice and license text shall be included in all copies 
or substantial portions of this Software.


Detailed description

Two parameters are used to control splitting: one to define the minimal 
length and another to define maximal length. A line part till minimal 
length is kept as is and then further the space is searching to make 
the split in that position. If space was not find then break happens 
at maximal length position.

The command below reads a text from standard input (console) and breaks 
line leaving at least of 70 symbols but not longer as 90 symbols. The 
break will be done at first space after 70th position. The result will 
be to standard output stream (console).

awk -f linebreak.awk 70 90

But it is possible to redirect a result into a file (by using >), for example, 
awk -f  linebreak.awk 70 90 > splited.txt

Input file could be taken from redirection into input stream (by using 
<), for example,

awk -f  linebreak.awk  70 90 <text.txt
or transferring in pipe (by using | ), for example,
more text.txt | awk -f  linebreak.awk 70 90
or providing in first position of command, for example,
awk -f  linebreak.awk text.txt 70 90

But even more - you can provide start position and maximal line length 
by using MIN and MAX variables rather than by script parameters. For example:
awk -v MIN=60 -v MAX=78 -f linebreak.awk text.txt

Note: script parameters overrides values transfered by variables.

Versions

1. First version was demo version. Its code is at page:
http://www.lithuanian.net/advancedhtml/awk2.htm#linebreak


