_ _ ___ | |__ __ _ _______ | |_ / _ \| '_ \ / _` |_ / _ \| __| | (_) | | | | (_| |/ / (_) | |_ \___/|_| |_|\__,_/___\___/ \__|
| ohazot | docs | links | dev | conf | txt |
| es | en |
| mdoc file |
| search |
tr —
translate characters
OPTIONS
| -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). |
EXAMPLES
$ echo "hello" | tr "l" "m" hemmo
control chacters
echo "hello" | tr 'e' '\n' h llo
echo 'hello' | tr 'l' '\t' he o
character range
echo 'hello' | tr 'h-l' 'a-d' aeddo
Character classes
echo '1.hello\n2.goodbye' | tr '[:digit:]' 'a-c' b.hello c.goodbye
TODO
- check character range.
- check octal.
- check repetitions.
SEE ALSO
- OpenBSD manpages: tr(1)