- 123
The tr command, short for "translate," is a powerful utility in Linux and Unix systems used for transforming and manipulating text data from standard input. It allows for operations such as character replacement, deletion, case conversion, and squeezing of repeated characters. The tr command is commonly used in conjunction with other commands through piping to achieve more complex text processing tasks.
Basic Syntax and Usage
The basic syntax of the tr command is as follows:
tr [OPTIONS] SET1 [SET2]The command works with two sets of characters, where SET1 is the set of characters to be replaced or removed, and SET2 is the set of characters to replace those in SET1. For example, to replace all occurrences of 'a' with 'b', you would use:
echo 'banana' | tr 'a' 'b'This would output 'bnnbnb'.
Character Classes and Ranges
Tr Command in Linux with Examples | Linuxize
Nov 27, 2019 · tr is a command-line utility in Linux and Unix systems that translates, deletes, and squeezes characters from the standard input and writes the result to the standard output. The tr command can perform operations like …
tr command in Unix/Linux with examples - GeeksforGeeks
tr (Unix) - Wikipedia
- People also ask
How to Use the Linux tr Command - How-To Geek
May 15, 2023 · The Linux tr command is a fast and simple utility for stripping out unwanted characters from streams of text, and for other neat manipulation tricks. It gets its name from the word "translate," and tr 's roots run deep in the Unix …
How to replace characters using `tr` in Linux? | LabEx
The basic syntax for replacing characters using the tr command is as follows: tr 'SET1' 'SET2'. Explain Code. Practice Now. Here, SET1 represents the characters you want to replace, and SET2 represents the characters you want …
tr Command in Linux: 6 Useful Examples - Linux …
The tr command in Linux is used to perform simple but useful translations of one set of characters into another. Learn some practical examples of tr command.
Linux tr Command - Baeldung
Mar 18, 2024 · tr is short for “translate”. It is a member of the GNU coreutils package. Therefore, it’s available in all Linux distros. The tr command reads a byte stream from standard input (stdin), translates or deletes characters, then …
The Complete Guide to the Bash tr Command – TheLinuxCode
Linux tr Command with Examples - phoenixNAP
May 10, 2022 · The tr command is a Linux command-line utility that translates or deletes characters from standard input (stdin) and writes the result to standard output (stdout). Use tr to perform different text transformations, including case …
Understanding Linux / UNIX tr command - nixCraft