freq

count frequencies of keys in text
git clone git://bvnf.space/freq.git
Log | Files | Refs | README

README (2340B)


      1
      2
      3
      4
      5
      6
      7
      8
      9
     10
     11
     12
     13
     14
     15
     16
     17
     18
     19
     20
     21
     22
     23
     24
     25
     26
     27
     28
     29
     30
     31
     32
     33
     34
     35
     36
     37
     38
     39
     40
     41
     42
     43
     44
     45
     46
     47
     48
     49
     50
     51
     52
     53
     54
     55
     56
     57
     58
     59
     60
     61
     62
     63
     64
     65
     66
     67
     68
     69
     70
FREQ(1)                     General Commands Manual                    FREQ(1)

NAME
     freq - count frequencies of keys in text

SYNOPSIS
     freq [-d delim] [-k key] [file ...]

DESCRIPTION
     freq counts the frequencies of each specified field for each line of text
     input from each file.  For each line, freq checks the field at the
     specified key and increments the count for that value of the field.  The
     rest of the line is ignored.

     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 <tab> character, then the value of the
     field.

     The following options are supported:

     -d delim
             Set the field delimiter to the character delim.  The default is
             any character of class space in the current locale (see
             isspace(3)).

     -k key  Count the frequencies of the field found at position key, where
             fields are separated by any number of delim characters.  The
             default value of key is 1, meaning that the first fields on each
             line are counted.  To use the whole line as a key, use the
             special value of 0.  If key fields are not found on a line, a
             warning is printed and the whole line is ignored.

OPERANDS
     file    A pathname of an input file.  If no file operand is specified, or
             if the file operand is `-', then standard input is used.  If file
             does not refer to a valid file, then the operand is ignored.

EXIT STATUS
     The freq utility exits 0 on success, and >0 if an error occurs.

EXAMPLES
     For a file named notes, containing the following data:

           I bought pears
           You sold apples
           I bought apples
           I bought oranges
           I sold bananas
           You ate bananas

     Below are some examples of various invocations of freq with their
     outputs:

           $ freq notes
           4       I
           2       You

           $ freq -k 2 notes
           3       bought
           2       sold
           1       ate

SEE ALSO
     cut(1), sort(1)

AUTHORS
     phoebos <ben@bvnf.space>

ben's space                     March 21, 2022                     ben's space