tr
The command that replaces, squeezes or deletes single characters as text passes through it.
In more detail
tr a-z A-Z maps one set onto another, tr -s ' ' squeezes runs of spaces into one, and tr -d deletes characters, as in tr -d ' ' to strip spaces from a count. It works on characters only and reads standard input, never a file name.
Example
tr '[:lower:]' '[:upper:]' <<< "quiet shell"Related terms
- sed — The stream editor, which applies editing commands such as find-and-replace to each line of text passing through it.
- character class — A regular expression or glob part in square brackets that matches any one character from a set, such as [abc] or [a-z].
- case modification — The ${name^^} and ${name,,} forms, which convert a value to upper or lower case; a single caret or comma changes only the first letter.
Taught in
- Pipelines, tee And Process Substitution — Bash Scripting & Command Line Automation
- Reshaping Text: cut, sort, uniq, tr, sed, awk — Bash Scripting & Command Line Automation
- Script Input And Output: read, Heredocs, printf — Bash Scripting & Command Line Automation
- POSIX sh Versus Bash — Bash Scripting & Command Line Automation
- Scheduling, Monitoring And A Script That Reports — Bash Scripting & Command Line Automation
- The Virtual File System: /proc, /sys, Binds And tmpfs — Linux Foundation Certified System Administrator (LFCS) Exam Prep
- Filters: Twenty Small Tools — LPIC-1 Linux Administrator (101-500 and 102-500) Exam Prep