It mentions that ,tr can also translate any number of specified characters into other characters. In such case, each of the two sets needs to be enclosed in square brackets, and these brackets, in turn, need to be enclosed in quotation marks. Either single of double quotation marks can be used.
I had seen example tr -d '\015' file1
working fine with out quotes or double quotes.
Can somebody tell me what exactly the input format for tr.
change one letter:
# echo hello world | tr -s "h" "k"
kello world
change two
# echo hello world | tr -s "hl" "kf"
kefo worfd
more powerful:
# echo hello world | tr "[a-z]" "[A-Z]"
HELLO WORLD
can specify shorter lists:
# echo hello world | tr "[a-g]" "[A-G]"
hEllo worlD
remember, each letter gets translated for pos_string_1 to pos_string_2:
# echo hello world | tr "[a-g]" "NGHRTYE"
hTllo worlR
deleting:
# echo hello world | tr -d "l"
heo word
squeezing:
# echo hello world | tr -s "l" "X"
heXo worXd
also - "man ascii" "\015 defines a single character"
There is no need for square brackets; they are a.o. used for ranges.
From the man page:
So in example 9, [ is mapped to t, ' is mapped to a and ] is also mapped to a.
In example 10, [ is mapped to t, ' is mapped to t and ] is also mapped to t.