TR(1)
๐ TR(1) ๐
okay so bestie, welcome to the User Commands section of the manual, and today's main character is tr. she's tiny, she's powerful, and she will absolutely change your life once you get what she's about. let's go ๐ซถ
โจ NAME โจ
tr โ translate or delete characters. that's it. that's her whole thing. she does one job and she ATE, no notes. ๐
โจ SYNOPSIS โจ
tr [OPTION]... STRING1 [STRING2]
โจ DESCRIPTION โจ
so basically: she translates, squeezes, and/or deletes characters coming in from standard input, and writes the glow-up to standard output. โจ STRING1 and STRING2 are the two strings you hand her โ they specify arrays of characters, ARRAY1 and ARRAY2, and those arrays are what actually control the action. think of them as the vibe and the destination vibe.
๐ the flags, bestie ๐
-c,-C,--complementโ use the complement ofARRAY1. i.e. everything she wasn't told about. ๐-d,--deleteโ delete the characters inARRAY1, do not translate. she's in her erasing era.-s,--squeeze-repeatsโ replace each sequence of a repeated character that's listed in the last specifiedARRAYwith a single occurrence of that character. so like, one of them, not forty. โจ-t,--truncate-set1โ first truncateARRAY1to the length ofARRAY2. (you'll see why below, iykyk)--helpโ display this help and exit. the "wait what does this do again" button.--versionโ output version information and exit. ๐
๐ฆ how you write an ARRAY ๐ฆ
ARRAYs are specified as strings of characters, and most characters just represent themselves. simple! but some of them are interpreted sequences, and those are the ones you actually need to know:
\NNNโ character with octal valueNNN(1 to 3 octal digits)\\โ backslash\aโ audible BEL (yes, she can scream at you ๐)\bโ backspace\fโ form feed\nโ new line\rโ return\tโ horizontal tab\vโ vertical tabCHAR1-CHAR2โ all characters fromCHAR1toCHAR2in ascending order[CHAR*]โ inARRAY2, copies ofCHARuntil length ofARRAY1[CHAR*REPEAT]โREPEATcopies ofCHAR,REPEAToctal if starting with 0[:alnum:]โ all letters and digits[:alpha:]โ all letters[:blank:]โ all horizontal whitespace[:cntrl:]โ all control characters[:digit:]โ all digits[:graph:]โ all printable characters, not including space[:lower:]โ all lower case letters[:print:]โ all printable characters, including space[:punct:]โ all punctuation characters[:space:]โ all horizontal or vertical whitespace[:upper:]โ all upper case letters[:xdigit:]โ all hexadecimal digits[=CHAR=]โ all characters which are equivalent toCHAR
๐ the actual rules of the road ๐
Translation occurs if -d is not given and both STRING1 and STRING2 appear. -t is only significant when translating. ARRAY2 is extended to the length of ARRAY1 by repeating its last character as necessary. excess characters of ARRAY2 are ignored. (so if you gave her too much, she just... looks away. iconic.)
Character classes expand in unspecified order โ and while translating, [:lower:] and [:upper:] may be used in pairs to specify case conversion. ๐
Squeezing occurs after translation or deletion. order matters, bestie.
โ ๏ธ real talk: arguments like [...] should be quoted, to avoid potential shell globbing. the shell will try to be the main character if you let it. quote your stuff. ๐ซถ
๐ BUGS ๐
Full support is available only for safe single-byte locales โ the ones where every possible input byte represents a single character. if you're in a locale where that's not true, she's not fully supported, periodt.
the good news: the C locale is safe in GNU systems, so you can dodge the whole issue in the shell by running LC_ALL=C tr instead of plain tr. ๐ง
๐ AUTHOR ๐
Written by Jim Meyering. give her father his flowers. ๐ธ
๐ REPORTING BUGS ๐
- Report bugs to: <bug-coreutils@gnu.org>.
- Report any translation bugs to: <https://translationproject.org/team/>.
- GNU coreutils home page: <https://www.gnu.org/software/coreutils/>
- General help using GNU software: <https://www.gnu.org/gethelp/>
๐ COPYRIGHT ๐
Copyright ยฉ 2026 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. (like, zero. none. don't come for her.) ๐ญ
๐ SEE ALSO ๐
- Full documentation <https://www.gnu.org/software/coreutils/tr>
- or available locally via:
info '(coreutils) tr invocation'
and that's the whole page bestie!! ๐ this was GNU coreutils 9.12, dated September 2026, and that's on TR(1). go squeeze something. literally anything. slay. โจ๐๐ฆ
๐ฆ where this page comes from
- arch rolling: coreutils 9.12-2 ยท GPL-3.0-or-later AND GFDL-1.3-or-later
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms