cat

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package cat implements the cat builtin command.

cat — concatenate and print files

Usage: cat [OPTION]... [FILE]...

Concatenate FILE(s) to standard output. With no FILE, or when FILE is -, read standard input.

Accepted flags:

-n, --number
    Number all output lines, starting at 1. Line numbers are
    right-justified in a 6-character field followed by a tab.

-b, --number-nonblank
    Number only non-blank output lines, starting at 1. Overrides -n.

-s, --squeeze-blank
    Squeeze multiple consecutive blank lines into a single blank line.

-E, --show-ends
    Display a $ character at the end of each line.

-T, --show-tabs
    Display TAB characters as ^I.

-v, --show-nonprinting
    Display non-printing characters using ^ and M- notation, except
    for line-feed and TAB.

-A, --show-all
    Equivalent to -vET.

-e
    Equivalent to -vE.

-t
    Equivalent to -vT.

-u
    Ignored (output is already unbuffered). Accepted for POSIX
    compatibility.

-h, --help
    Print usage to stdout and exit 0.

Exit codes:

0  All files processed successfully.
1  At least one error occurred (missing file, permission denied, etc.).

Memory safety:

All processing is streaming: input is read line-by-line with a per-line
cap of MaxLineBytes (1 MiB). Lines exceeding this cap cause an error
rather than an unbounded allocation. All read loops check ctx.Err() at
each iteration to honour the shell's execution timeout and support
graceful cancellation.

Index

Constants

View Source
const MaxLineBytes = 1 << 20 // 1 MiB

MaxLineBytes is the per-line buffer cap for the line scanner. Lines longer than this are reported as an error instead of being buffered.

Variables

View Source
var Cmd = builtins.Command{Name: "cat", MakeFlags: registerFlags}

Cmd is the cat builtin command descriptor.

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

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