tr
all
Translate characters: run replacements based on single characters and character sets.
More info →Options (3)
-d, --deletebooleanDelete all occurrences of the specified set of characters from the input
Example:
tr < {{path/to/file}} {{[-d|--delete]}} '{{input_characters}}'-s, --squeeze-repeatsbooleanCompress a series of identical characters to a single character
Example:
tr < {{path/to/file}} {{[-s|--squeeze-repeats]}} '{{input_characters}}'booleanStrip out non-printable characters from a file
Example:
tr < {{path/to/file}} {{[-cd|--complement --delete]}} "[:print:]"Examples (7)
Replace all occurrences of a character in a file, and print the result
tr < path/to/file find_character replace_characterReplace all occurrences of a character from another command's output
Map each character of the first set to the corresponding character of the second set
tr < path/to/file 'abcd' 'jkmn'Delete all occurrences of the specified set of characters from the input
tr < path/to/file [-d|--delete] 'input_characters'Compress a series of identical characters to a single character
tr < path/to/file [-s|--squeeze-repeats] 'input_characters'Translate the contents of a file to upper-case
tr < path/to/file "[:lower:]" "[:upper:]"Strip out non-printable characters from a file
tr < path/to/file [-cd|--complement --delete] "[:print:]"made by @shridhargupta | data from tldr-pages