Linux tr command (translate)

The tr command is used to translate text.

Example

root@ok:~# echo "serverok" | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ
SERVEROK
root@ok:~# 

You can also use

root@ok:~# echo "serverok" | tr "a-z" "A-Z"
SERVEROK
root@ok:~# 

To change specific chars

root@ok:~# echo "serverok" | tr "sok" "SOK"
ServerOK
root@ok:~# 

To delete char, use -d option

root@ok:~# echo "serverok" | tr -d "ok"
server
root@ok:~# 

See Linux Commands

Need help with Linux Server or WordPress? We can help!

Leave a Reply

Your email address will not be published. Required fields are marked *