Plan 9 from Bell Labs’s /usr/web/sources/contrib/alltom/f

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


#!/bin/awk -f
# f - format text into 72-char lines
# taken from Brian Kernighan's COS 333 slides

/./ { for (i = 1; i <= NF; i++) addword($i) }
/^$/ { printline(); print "" }
END { printline() }

function addword(w) {
	if (length(line) + length(w) > 72)
		printline()
	line = line space w
	space = " "
}

function printline() {
	if (length(line) > 0)
		print line
	line = space = ""
}

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to [email protected].