Plan 9 from User Space's /usr/local/plan9/src/cmd/index/range.prep

awk ' # range.prep
#   Input:  ["%begin"|"%end"|""] string (tab) number
#   Output: string (tab) ["b"|"e"|"a"]  (tab) number

BEGIN		{ FS = OFS = "\t" }
		{ f2 = "a" }
$1 ~ /^%begin/	{ f2 = "b"; sub(/^%begin */, "", $1) }
$1 ~ /^%end/	{ f2 = "e"; sub(/^%end */, "", $1) }
		{ print $1, f2, $2 }
' $*

Space Glenda

Copyright © 2005 Lucent Technologies, Russ Cox, MIT.
See license for details.