Linux Commands Helper
💬 Your AI-powered Linux assistant
tr Command - Translate or Delete Characters
The tr command is used to translate, squeeze, or delete characters from standard input and write the result to standard output. It is commonly used for text processing in pipelines.
Syntax
tr [options] SET1 [SET2]
Examples
echo "hello world" | tr 'a-z' 'A-Z'
Convert lowercase letters to uppercase.
echo "hello world" | tr -s ' '
Squeeze multiple spaces into a single space.
echo "hello,world" | tr -d ','
Delete commas from the input.
Notes
- Works only with single-byte characters (not multibyte/Unicode).
- Commonly used in shell pipelines for simple text transformations.
- For field extraction, see
cut
.