Windows
Linux
Text Processing
Windows findstr (character replace — n/a) equivalent in Linux
Replaces, deletes, or squeezes individual characters in text — a character-level find and replace.
Windows
→
findstr (character replace — n/a)
Linux equivalents
tr
tr
tr
Overview
What this command does
Replaces, deletes, or squeezes individual characters in text — a character-level find and replace.
Migration tip:
tr works on individual characters, not strings. For string replacement use sed. tr -d '\r' is the quickest fix for Windows line endings in text files.Practical tasks
Common use cases
Translate or delete characters
Replaces, deletes, or squeezes individual characters in text — a character-level find and replace.
tr 'a-z' 'A-Z'
Convert to uppercase
tr 'A-Z' 'a-z'
Convert to lowercase
tr -d '\r'
Remove Windows carriage returns (\r\n → \n)
Ready to run
Copyable Linux commands
Review paths, device names, package names and permissions before running any command.
echo 'hello world' | tr 'a-z' 'A-Z'
tr -d '\r' < windows_file.txt > fixed.txt
echo 'Hello, World!' | tr -d '[:punct:]'
Walkthrough
Examples with explanations
# No direct Windows CMD equivalent
# Uppercase:
echo 'hello world' | tr 'a-z' 'A-Z'
HELLO WORLD
# Fix Windows line endings:
tr -d '\r' < windows_file.txt > fixed.txt
# Remove all punctuation:
echo 'Hello, World!' | tr -d '[:punct:]'
Reference
Common options and variations
| Command or option | Use |
|---|---|
tr 'a-z' 'A-Z' | Convert to uppercase |
tr 'A-Z' 'a-z' | Convert to lowercase |
tr -d '\r' | Remove Windows carriage returns (\r\n → \n) |
tr -s ' ' | Squeeze multiple spaces into one |
tr -d '[:digit:]' | Delete all digits |
Distro differences
Debian/Ubuntu vs Fedora vs Arch
This command is the same on Debian/Ubuntu, Fedora and Arch Linux when the relevant tool is installed.
| Distribution | Package manager / base | Equivalent command | Difference to notice |
|---|---|---|---|
| Debian/Ubuntu | same command | tr |
Same command on this distribution. |
| Fedora | same command | tr |
Same command on this distribution. |
| Arch | same command | tr |
Same command on this distribution. |
Keep learning