The tr command in Linux is a utility used for translating, deleting, or squeezing characters from standard input and writing the result to standard output.
Basic Syntax:
tr [OPTION]... SET1 [SET2]
- SET1: The set of characters to be translated or deleted.
- SET2: The set of characters that will replace those in SET1 (used for translation).
Common Options:
-d: Delete characters in SET1.-s: Squeeze repeated characters into a single occurrence.
Examples:
-
Translate lowercase to uppercase:
tr 'a-z' 'A-Z' < input.txt -
Delete specific characters:
tr -d 'abc' < input.txt -
Squeeze repeated spaces:
tr -s ' ' < input.txt
The tr command is useful for text processing tasks, such as cleaning up data or formatting text. If you need more specific examples or have questions about its usage, let me know!
