tr [options] SET1 [SET2]
Replace characters with other characters
echo abcde | tr "ae" "-" # → -bcd-
# truncate SET1
echo abcde | tr -t "ae" "-" # → -bcde
# split pathsep into newlines
echo $PATH | tr ":" "\n"
Remove repeating characters
echo aabbccddee | tr -s "bcd" # → aabcdee
echo "foo bar" | tr -s " " # → foo bar
Remove characters
echo aabbcc | tr -d "ab" # -> cc
Replace anything NOT in SET1
# note the inclusion of newline
echo "abcde" | tr -c "ae\n" "-" # -> a---e
# read from /dev/urandom
# discard anything not alphanumeric
# continue until we have 32 chars
tr -cd '[:alnum:]' </dev/urandom | dd bs=32 count=1 2>/dev/null