freq

unnamed repository
Log | Files | Refs

commit d1099db7a31d99400512c99357b0584e7bf445ce
parent 8225f9e5aa237f6a22c6d733a7dfe3f775f2d153
Author: phoebos <ben@bvnf.space>
Date:   Mon, 21 Mar 2022 18:53:42 +0000

add manpage

Diffstat:
Afreq.1 | 86+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 86 insertions(+), 0 deletions(-)

diff --git a/freq.1 b/freq.1 @@ -0,0 +1,86 @@ +.Dd "March 21, 2022" +.Dt FREQ 1 +.Os "ben's space" +.Sh NAME +.Nm freq +.Nd count frequencies of keys in text +.Sh SYNOPSIS +.Nm +.Op Fl k Ar key +.Op Ar file +.Sh DESCRIPTION +.Nm +counts the frequencies of each specified field for each line of text input. +For each line, +.Nm +checks the field at the specified +.Ar key +and increments the count for that value of the field. +The rest of the line is ignored. +.Pp +After checking every line, the counts for each value are printed, in the order +in which they are encountered for the first time. +The results are printed with the frequency, then a +.Aq tab +character, then the value of the field. +.Pp +The following options are supported: +.Bl -tag -width Ds +.It Fl k Ar key +Count the frequencies of the field found at position +.Ar key , +where fields are separated by any number of space characters in the current locale (see +.Xr isspace 3 ) . +The default value of +.Ar key +is 1, meaning that the first fields on each line are counted. +If +.Ar key +fields are not found on a line, a warning is printed and the whole line is ignored. +.El +.Sh OPERANDS +.Bl -tag -width Ds +.It Ar file +A pathname of an input file. +If no +.Ar file +operand is specified, or if the +.Ar file +operand is +.Sq - , +then standard input is used. +.El +.Sh EXIT STATUS +.Ex -std +.Sh EXAMPLES +For a file named +.Pa notes , +containing the following data: +.Bd -literal -offset indent +I bought pears +You sold apples +I bought apples +I bought oranges +I sold bananas +You ate bananas +.Ed +.Pp +Below are some examples of various invocations of +.Nm +with their outputs: +.Bd -literal -offset indent +$ freq notes +4 I +2 You +.Ed +.Bd -literal -offset indent +$ freq -k 2 notes +3 bought +2 sold +1 ate +.Ed +.Sh SEE ALSO +.Xr cut 1 , +.Xr sort 1 +.Sh AUTHORS +.An phoebos Aq Mt ben@bvnf.space