{
    "mode": "perldoc",
    "parameter": "tr",
    "section": "-f",
    "url": "https://www.chedong.com/phpMan.php/perldoc/tr/json",
    "generated": "2026-06-03T04:24:15Z",
    "sections": [],
    "flags": [],
    "examples": [],
    "see_also": [],
    "tldr": {
        "source": "official",
        "description": "Translate characters: run replacements based on single characters and character sets.",
        "examples": [
            {
                "description": "Replace all occurrences of a character in a file, and print the result",
                "command": "tr < {{path/to/file}} {{find_character}} {{replace_character}}"
            },
            {
                "description": "Replace all occurrences of a character from another command's output",
                "command": "echo {{text}} | tr {{find_character}} {{replace_character}}"
            },
            {
                "description": "Map each character of the first set to the corresponding character of the second set",
                "command": "tr < {{path/to/file}} '{{abcd}}' '{{jkmn}}'"
            },
            {
                "description": "Delete all occurrences of the specified set of characters from the input",
                "command": "tr < {{path/to/file}} {{-d|--delete}} '{{input_characters}}'"
            },
            {
                "description": "Compress a series of identical characters to a single character",
                "command": "tr < {{path/to/file}} {{-s|--squeeze-repeats}} '{{input_characters}}'"
            },
            {
                "description": "Translate the contents of a file to upper-case",
                "command": "tr < {{path/to/file}} \"[:lower:]\" \"[:upper:]\""
            },
            {
                "description": "Strip out non-printable characters from a file",
                "command": "tr < {{path/to/file}} {{-cd|--complement --delete}} \"[:print:]\""
            }
        ]
    }
}