TR(1)

πŸ“¦
version 9.10 Β· 5 versions
, in ubuntu stonking

πŸ’– TR(1) β€” or, the translate/deletes-characters girlie πŸ’–

hiii bestie, welcome to the tr(1) page from the User Commands manual ✨ this is the tool that takes characters on stdin, does a lil glow-up on them, and hands them back on stdout. she's simple, she's iconic, she's in every shell script you've ever copy-pasted. let's go 🫢


🌸 NAME 🌸

tr β€” translate or delete characters πŸ’…


✨ SYNOPSIS ✨

tr [OPTION]... STRING1 [STRING2]

πŸ¦‹ DESCRIPTION πŸ¦‹

okay so here's the whole vibe: tr translates, squeezes, and/or deletes characters from standard input, and writes the result to standard output. πŸ’« Your STRING1 and STRING2 are what spell out the character arrays ARRAY1 and ARRAY2, which are literally the things that control what action happens. no cap.

Here's the flag menu, and yes every single one is here πŸ‘‡

  • -c, -C, --complement β€” use the complement of ARRAY1 (i.e. everything she's not listing)
  • -d, --delete β€” delete the characters in ARRAY1, do not translate. just straight up removal, rip πŸ’€
  • -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 🫧
  • -t, --truncate-set1 β€” first truncate ARRAY1 to length of ARRAY2 βœ‚οΈ
  • --help β€” display this help and exit πŸ₯°
  • --version β€” output version information and exit πŸ“¦

πŸŽ€ how you write ARRAYs πŸŽ€

ARRAYs are specified as strings of characters. Most represent themselves (so boring, so reliable). But the interpreted sequences are where the drama lives β€” here's the full list, don't skip a single one:

  • \NNN β€” character with octal value NNN (1 to 3 octal digits) πŸ”’
  • \\ β€” backslash
  • \a β€” audible BEL πŸ””
  • \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 mechanics, bestie πŸ’«

Translation occurs if -d is not given and both STRING1 and STRING2 appear. -t is only significant when translating. ARRAY2 is extended to length of ARRAY1 by repeating its last character as necessary. Excess characters of ARRAY2 are ignored. Character classes expand in unspecified order; while translating, [:lower:] and [:upper:] may be used in pairs to specify case conversion. Squeezing occurs after translation or deletion.

⚠️ okay important: arguments like [...] should be quoted, to avoid potential shell globbing. your shell will absolutely try to eat your brackets if you let it. quote it, queen πŸ‘‘

😭 BUGS 😭

Full support is available only for safe single-byte locales, in which every possible input byte represents a single character. The C locale is safe in GNU systems, so you can dodge this whole issue in the shell by running LC_ALL=C tr instead of plain tr. slay 🐚


🫢 AUTHOR 🫢

Written by Jim Meyering. king behavior, honestly.


πŸ“£ REPORTING BUGS πŸ“£


πŸ‘€ SEE ALSO πŸ‘€


okay and for the record, this build was Packaged by Ubuntu (9.10-1ubuntu2) πŸ’œ

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. πŸ™ˆ

and that's the whole page bestie, mwah πŸ’‹ this was GNU coreutils 9.10, dated August 2026 β€” go translate something iconic with her, you got this πŸ¦‹βœ¨πŸ’–

πŸ“¦ where this page comes from