commands
tr — translate or delete characters
Translate characters from stdin to stdout; -d deletes selected characters, -s squeezes repeats. No filename operand. GNU tr has multibyte limitations; use C locale for ASCII fixtures. Example assumes a fresh text-streams lab fixture.
Formal Syntax & Structure
linux syntaxlinux
tr [OPTION]... STRING1 [STRING2]Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| STRING1 | operand | First character array specification; not an arbitrary regular expression. |
| STRING2 | operand | Second array, required for translation and for -ds; omit for delete-only or single-array squeeze. |
| -d | option | Delete characters in first array; do not translate. |
| -s | option | Squeeze consecutive occurrences of characters in the last specified array. |
Return Value
exit status and output
GNU tr transforms stdin into stdout and returns nonzero on read/write or option errors. No matching characters is a successful unchanged result, not a no-match status.
Working Example
Example Snippetlinux
LC_ALL=C tr '[:lower:]' '[:upper:]' < names.txt