Команда tr

Translate characters.

Синтаксис

tr [-c] [-d] [-s] [string1] [string2]

-cComplement the set of characters specified by string1.
-dDelete all occurrences of input characters that are specified by string1.
-sReplace instances of repeated characters with a single character.
string1First string or character to be changed.
string2Second string or character to change the string1.

Примеры

echo "12345678 9247" | tr 123456789 computerh - this example takes an echo response of '12345678 9247' and pipes it through the tr replacing the appropriate numbers with the letters. In this example it would return computer hope.

tr -cd '\11\12\40-\176' < myfile1 > myfile2 - this example would take the file myfile1 and strip all non printable characters and take that results to myfile2.

Обратно к списку команд