tr is used to translate, squeeze, and/or delete characters from standard input, writing to standard output.
tr command is usually used alone side with other command.
echo "Hello World" | tr [a-z] [A-Z]
# or echo "Hello World" | tr [:lower:] [:upper:]
----
# output:
HELLO WORLD
echo "Hello World!" | tr "!" "."
----
# output:
Hello World.
You can also delete character with tr command
echo "Hello World" | tr -d [a-z]
----
# output:
H W
Another feature is squeeze, we can remove the duplicate character
echo "localhostt" | tr -s "t"
----
# output:
localhost
Other arguement
[:alnum:] all letters and digits
[:alpha:] all letters
[:blank:] all horizontal whitespace
[:digit:] all digits
[:graph:] all printable characters, not including space
[:lower:] all lower case letters
[:print:] all printable characters, including space
[:punct:] all punctuation characters
[:space:] all horizontal or vertical whitespace
[:upper:] all upper case letters
Leave a comment if you have any questions.
===========
Please keep in touch
Portfolio
Linkedin
Github
Youtube