text

package
v1.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 10, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RunSort

func RunSort(w io.Writer, r io.Reader, args []string, opts SortOptions) error

RunSort executes the sort command r is the default input reader (used when args is empty or contains "-")

func RunUniq

func RunUniq(w io.Writer, r io.Reader, args []string, opts UniqOptions) error

RunUniq executes the uniq command r is the default input reader (used when args is empty or contains "-")

func Sort

func Sort(lines []string)

Sort sorts a slice of strings in place (for compatibility)

func TrimLines

func TrimLines(lines []string) []string

TrimLines trims whitespace from all lines (for compatibility)

func Uniq

func Uniq(lines []string) []string

Uniq returns unique lines from a slice (for compatibility)

Types

type SortOptions

type SortOptions struct {
	Reverse       bool   // -r: reverse the result of comparisons
	Numeric       bool   // -n: compare according to string numerical value
	Unique        bool   // -u: output only unique lines
	IgnoreCase    bool   // -f: fold lower case to upper case characters
	IgnoreLeading bool   // -b: ignore leading blanks
	Dictionary    bool   // -d: consider only blanks and alphanumeric characters
	Key           string // -k: sort via a key
	FieldSep      string // -t: use SEP as field separator
	Check         bool   // -c: check for sorted input
	Stable        bool   // -s: stabilize sort by disabling last-resort comparison
	Output        string // -o: write result to FILE
	JSON          bool   // --json: output as JSON
}

SortOptions configures the sort command behavior

type SortResult

type SortResult struct {
	Lines []string `json:"lines"`
	Count int      `json:"count"`
}

SortResult represents sort output for JSON

type UniqLine

type UniqLine struct {
	Line  string `json:"line"`
	Count int    `json:"count"`
}

UniqLine represents a line with its count for JSON

type UniqOptions

type UniqOptions struct {
	Count         bool // -c: prefix lines by the number of occurrences
	Repeated      bool // -d: only print duplicate lines
	AllRepeated   bool // -D: print all duplicate lines
	IgnoreCase    bool // -i: ignore differences in case
	Unique        bool // -u: only print unique lines
	SkipFields    int  // -f: avoid comparing the first N fields
	SkipChars     int  // -s: avoid comparing the first N characters
	CheckChars    int  // -w: compare no more than N characters
	ZeroTerminate bool // -z: line delimiter is NUL, not newline
	JSON          bool // --json: output as JSON
}

UniqOptions configures the uniq command behavior

type UniqResult

type UniqResult struct {
	Lines []UniqLine `json:"lines"`
	Count int        `json:"count"`
}

UniqResult represents uniq output for JSON

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL