_                    _
  ___ | |__   __ _ _______ | |_
 / _ \| '_ \ / _` |_  / _ \| __|
| (_) | | | | (_| |/ / (_) | |_
 \___/|_| |_|\__,_/___\___/ \__|

trtranslate 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.

(back to top)

text_processing
OpenBSD manpages: tr(1)

(back to top)

2025-10-03 : Created.

(back to top)

ohazot | about | ohazot.com <admin@ohazot.com>

This document applies to: OpenBSD 7.7 linux| 2025-10-21