Skip to content

Latest commit

 

History

History
executable file
·
372 lines (285 loc) · 9.74 KB

File metadata and controls

executable file
·
372 lines (285 loc) · 9.74 KB

Usage

findLineLengths [files]

Displays the length and position of lines of each file whose lengths are under --min characters long (default 0, so there won't be any), or over --max (default 80).

Can also produce:

a --table of lines by their lengths,
* cumulative percentage of lines by length,
* average line length,
* the line lengths for quartiles, deciles, etc (--iles n)

Note: Use the --where option to get a list of all the particular lines of chosen lengths.

Options

  • --count

    Synonym for --table.

  • --iencoding s

    Set character encoding for input.

  • --iles n

    Display a partial table showing the number of lines at each quartile, decile, etc. (for n = 4, 10, etc.).

  • --longest

    Just report the longest line found and its length.

  • --listencodings

    Show all the encodings supported by --iencoding, and exit.

  • --max n

    Report results for lines over n characters long.

  • --min n

    Only report results for lines less then n characters long.

  • -n

    Synonym for --where.

  • --newline (or --nl)

    Count CR, LF, or CRLF at the end? (default on; use --nonewline to turn off).

  • --quiet

    Suppress most messages.

  • --show

    Include the text of the first line of the longest length found (default).

  • --stats

    Report some extra statistics about line lenghts.

  • --table or --count

    Print how many lines of each length, and the percent of all lines that are not longer than that.

  • --unicode

    Synonym for --iencoding utf8.

  • --version

    Display version info and exit (sjd).

  • --where (or -n)

    Report line numbers for all lines of each length.

Known bugs and limitations

  • BSD wc does not have the -L option. However, this script provides --longest to do the same thing.

History

* Written 2006-01-12 to 06-28 by Steven J. DeRose.
* 2006-11-28 sjd: Sync to template, add --where, --min, -q, --version.
* 2007-11-09 sjd: strict. Add --nl. Print % and cumulative %.
* 2008-01-24 sjd: Getopt.
* 2008-03-27 sjd: Fix names.
* 2010-03-27 sjd: Adjust for fact that BSD's 'wc' lacks -L. Perldoc.
Make handle multiple input files. Unicode.
* 2011-07-14 sjd: Cleanup.
* 2011-10-19 sjd: Suppress output for lengths that have no lines.
* 2011-10-28 sjd: Report line number of longest line(s). Add --show.
* 2011-11-30 sjd: Add --stats, --max, --listEncodings, --iles.
Show total number of lines over --min length.
* 2014-12-11: Add ---longest. Fix --min/--max bugs.
* 2017-04-14: Fix STDIN.
* 2018-09-28: Make --count the default.
* 2024-11-01: Layout. Add --descending.

Ownership

This work by Steven J. DeRose is licensed under a Creative Commons Attribution-Share Alike 3.0 Unported License. For further information on this license, see http://creativecommons.org/licenses/by-sa/3.0/.

For the most recent version, see http://www.derose.net/steve/utilities/.

POD ERRORS

Hey! The above document had some coding errors, which are explained below:

Around line 26:

Expected text after =item, not a bullet

Around line 28:

Expected text after =item, not a bullet

Around line 30:

Expected text after =item, not a bullet