_ _
___ | |__ __ _ _______ | |_
/ _ \| '_ \ / _` |_ / _ \| __|
| (_) | | | | (_| |/ / (_) | |_
\___/|_| |_|\__,_/___\___/ \__|
tr —
translate characters
| -d |
delete characters |
| -s |
squeeze repeats |
Characters can be specified as a character, class, range.
| class |
: [:class:] |
|
: alpha, alnum, digit, cntrl, upper, lower, print, space, punct. |
| range |
: aA0-zZ9 (the beginning of the range is excluded). |
$ echo "hello" | tr "l" "m"
hemmo
echo "hello" | tr 'e' '\n'
h
llo
echo 'hello' | tr 'l' '\t'
he o
echo 'hello' | tr 'h-l' 'a-d'
aeddo
echo '1.hello\n2.goodbye' | tr '[:digit:]' 'a-c'
b.hello
c.goodbye
(back to top)
| - check character range. |
| - check octal. |
| - check repetitions. |
| - Translate to Spanish. |