Linux Commands Reference - Complete Linux Command Guide

Comprehensive Linux command reference with 150+ commands. Search, filter by category, and view detailed usage examples.

Share
Back to commands

tr

Translate or delete characters

Syntax

tr [OPTION]... SET1 [SET2]

Common Options

-dDelete characters
-sSqueeze repeated characters
-cUse complement of SET1
-tTruncate SET1 to SET2 length

Common Examples

tr 'a-z' 'A-Z' < file.txt

Convert to uppercase

tr -d '0-9' < file.txt

Delete all digits

tr -s ' ' < file.txt

Squeeze multiple spaces

echo 'hello' | tr 'a-z' 'A-Z'

Translate characters

tr -d '\r' < win.txt > unix.txt

Remove Windows carriage returns

tr -c 'a-zA-Z0-9' '_' < file.txt

Replace non-alphanumeric chars

Related Commands

Related Tools

More Code & Dev Tools