TR(1)

πŸ“¦ version 1.053, in alpine 3.24

πŸ’… TR(1) β€” translate or delete characters πŸ’…

okay so bestie, this is the tr page from the User Contributed Perl Documentation, and the manual name is TR(1). The tool is tr, and it's lowkey iconic for remixing characters on the fly. 🫢

✨ NAME ✨

tr β€” translate or delete characters. That's the whole vibe. πŸ’…

🌸 SYNOPSIS 🌸

tr [ -Ccds ] [ SEARCHLIST [ REPLACEMENTLIST ] ]

πŸ¦‹ DESCRIPTION πŸ¦‹

The tr program copies standard input to standard output while substituting or deleting selected characters. Input characters found in SEARCHLIST get mapped into the corresponding characters of REPLACEMENTLIST. When REPLACEMENTLIST is short, it's padded to the length of SEARCHLIST by duplicating its last character. ✨

Here are the options, bestie:

  • -C β€” Complement the SEARCHLIST.
  • -c β€” The same as -C.
  • -d β€” Delete found but unreplaced characters.
  • -s β€” Squash duplicate replaced characters.

In either string, the notation a-b means a range of characters from a to b in increasing ASCII order. Customary Perl escapes are honored, such as \n for newline, \012 for octal, and \x0A for hexadecimal codes. πŸŽ€

If the -c flag is specified, the SEARCHLIST character set is complemented. If the -d flag is specified, any characters specified by SEARCHLIST not found in REPLACEMENTLIST are deleted. (Note that this is slightly more flexible than the behavior of some tr programs, which delete anything they find in the SEARCHLIST, period.) If the -s flag is specified, sequences of characters that were transliterated to the same character are squashed down to a single instance of the character. πŸ’–

If the -d flag is used, the REPLACEMENTLIST is always interpreted exactly as specified. Otherwise, if the REPLACEMENTLIST is shorter than the SEARCHLIST, the final character is replicated till it is long enough. If the REPLACEMENTLIST is empty, the SEARCHLIST is replicated. This latter is useful for counting characters in a class or for squashing character sequences in a class. 🌈

πŸŽ€ EXAMPLES πŸŽ€

The following command creates a list of all the words in file1 one per line in file2, where a word is taken to be a maximal string of alphabetics.

tr -cs A-Za-z "\n" <file1 >file2

The following command strips the 8th bit from an input file:

tr "\200-\377" "\000-\177"

πŸ‘‘ NOTE πŸ‘‘

This command is implemented using Perl's tr operator. See the documentation in perlop for details on its operation. iykyk. πŸ’œ

πŸ’€ BUGS πŸ’€

tr has no known bugs. periodt. ✨

🫢 AUTHOR 🫢

Tom Christiansen, tchrist@perl.com.

This program is copyright (c) Tom Christiansen 1999.

This program is free and open software. You may use, modify, distribute, and sell this program (and any modified variants) in any way you wish, provided you do not restrict others from doing the same.


cute sign-off: from the User Contributed Perl Documentation, perl v5.42.2, dated 2026-02-15, manual TR(1) β€” periodt. πŸŽ€

πŸ“¦ where this page comes from