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 of ARRAY1. i.e. everything she wasn't told about. ๐Ÿ’€
  • -d, --delete โ€” delete the characters in ARRAY1, 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 specified ARRAY with a single occurrence of that character. so like, one of them, not forty. โœจ
  • -t, --truncate-set1 โ€” first truncate ARRAY1 to the length of ARRAY2. (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 value NNN (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 tab
  • CHAR1-CHAR2 โ€” all characters from CHAR1 to CHAR2 in ascending order
  • [CHAR*] โ€” in ARRAY2, copies of CHAR until length of ARRAY1
  • [CHAR*REPEAT] โ€” REPEAT copies of CHAR, REPEAT octal 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 to CHAR

๐Ÿ’œ 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 ๐ŸŒˆ


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 ๐Ÿ“


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