cat

package
v0.0.18 Latest Latest
Warning

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

Go to latest
Published: May 15, 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.

--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:

When line-processing flags are active (-n, -b, -s, -E, -T, -v), 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.
Without flags, input is streamed in fixed-size chunks (no per-line cap).
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",
	Description: "concatenate and print files",
	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