kato/kato.1
Juhani Krekelä e9da39f1ba Allow omitting the start/end of a lines range
Omitting the starting line is not useful, since it's just the same as
"1-ending line", but it makes no sense to forbid that if omitting the
ending line is allowed.
2026-09-14 21:06:55 +03:00

98 lines
2.2 KiB
Groff

.Dd September 14, 2026
.Dt KATO 1
.Os
.Sh NAME
.Nm kato
.Nd view potentially malformed text files
.Sh SYNOPSIS
.Nm
.Op Fl hrt
.Op Fl l Ar lines
.Op Ar
.Sh DESCRIPTION
.Nm
prints the contents of text files to the terminal.
Invalid UTF-8, control characters other than tab and newline, and
noncharacters are escaped in the output.
.Pp
If multiple files are specified (or the
.Fl h , Fl -header
option is given)
.Nm
prints a header showing the file name of each file before its contents.
.Nm
also prints a trailer after the file contents if the file was empty, did
not end with a newline, or (if the
.Fl l , Fl -lines
option is given) did not contain all the lines in the specified range.
.Pp
.Nm
expects the terminal to support UTF-8 and common ANSI SGR control codes.
.Pp
If no
.Ar file
is specified, or if
.Ar file
is
.Dq - ,
.Nm
reads from the standard input.
.Pp
The options are as follows:
.Bl -tag -width Ds
.It Fl h , Fl -header
Unconditionally print the header containing the file name.
.It Fl r , Fl -crlf
Allow CR + LF line endings.
By default
.Nm
will always escape a carriage return as
.Ql \er .
With this option, a carriage return just before a newline is ignored.
.It Fl t , Fl -escape-tab
Don't pass a tab character through as-is, but escape it as
.Ql \et .
.It Fl l , Fl -lines Ar lines
Print only the specified
.Ar lines
from each file.
.Pp
.Ar lines
can be either a single number, specifying a single line to print, or a
range separated by
.Sq - ,
e.g.\&
.Ql 10-94 .
If the starting point of a range is not specified
.Pq e.g. Ql -94 ,
the range is from the start of the file to the specified line.
If the ending point is not specified
.Pq e.g. Ql 10- ,
the range is from the specified line until the end of the file.
.El
.Sh EXIT STATUS
.Bl -tag -width Ds -compact
.It 0
Success
.It 1
Error while displaying the file or printing an error message
.It 64
Bad argument or option on the command line
.El
.Sh SEE ALSO
.Xr bat 1 ,
.Xr cat 1
.Sh STANDARDS
.Rs
.%D 2025
.%R RFC 9839
.%T Unicode Character Repertoire Subsets
.Re
.Nm
uses the
.Dq Unicode Assignables
subset, with the exception of carriage return (unless
.Fl r , Fl -crlf
is used).
.Sh AUTHORS
.An Juhani Krekelä Aq Mt juhani@krekelä.fi