Documentation
¶
Overview ¶
Package tr implements the tr builtin command.
tr — translate, squeeze, and/or delete characters
Usage: tr [OPTION]... SET1 [SET2]
Translate, squeeze, and/or delete characters from standard input, writing to standard output.
Accepted flags:
-d, --delete
Delete characters in SET1; do not translate.
-s, --squeeze-repeats
Replace each sequence of a repeated character that is listed
in the last specified SET with a single occurrence of that
character.
-c, -C, --complement
Use the complement of SET1 (all byte values NOT in SET1).
-t, --truncate-set1
First truncate SET1 to the length of SET2 when translating.
-h, --help
Print this usage message to stdout and exit 0.
SET notation:
Ranges: a-z, A-Z, 0-9
Character classes: [:alnum:], [:alpha:], [:blank:], [:cntrl:],
[:digit:], [:graph:], [:lower:], [:upper:],
[:print:], [:punct:], [:space:], [:xdigit:]
Equivalence class: [=c=] (matches the literal character c)
Repeat: [c*n] (repeat char c, n times; [c*] fills, SET2 only)
Backslash escapes: \a \b \f \n \r \t \v \\ \NNN (octal)
Exit codes:
0 Success. 1 Error (invalid arguments, read error, etc.).
Memory safety:
tr operates on a byte-at-a-time basis using a 256-entry lookup table. Input is read in fixed-size chunks (32 KiB). No allocation is proportional to input size. All loops check ctx.Err() to honour the shell's execution timeout.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var Cmd = builtins.Command{
Name: "tr",
Description: "translate or delete characters",
MakeFlags: registerFlags,
}
Cmd is the tr builtin command descriptor.
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.