Abbreviation of TR tracslate
In example 1, replace lowercase R with uppercase R.
shuohailhl@shuohailhl-PC /cygdrive/d$ cat pass.txtroot:x:0:0:root:/root:/bin/bashbin:x:1:1:bin:/bin:/sbin/nologindaemon:x:2:2:daemon:/sbin:/sbin/nologinadm:x:3:4:adm:/var/adm:/sbin/nologinshuohailhl@shuohailhl-PC /cygdrive/d$ tr 'r' 'R' < ./pass.txtRoot:x:0:0:Root:/Root:/bin/bashbin:x:1:1:bin:/bin:/sbin/nologindaemon:x:2:2:daemon:/sbin:/sbin/nologinadm:x:3:4:adm:/vaR/adm:/sbin/nologin
Example 2 replace all lowercase letters with uppercase letters
$ tr '[a-z]' '[A-Z]' < ./pass.txtROOT:X:0:0:ROOT:/ROOT:/BIN/BASHBIN:X:1:1:BIN:/BIN:/SBIN/NOLOGINDAEMON:X:2:2:DAEMON:/SBIN:/SBIN/NOLOGINADM:X:3:4:ADM:/VAR/ADM:/SBIN/NOLOGIN
Example 3
Shuohailhl @ shuohailhl-PC/cygdrive/d $ A = 'echo 123456789 | tr '1-9' '[A * 5] 'bcde' # Replace the first five characters with ashuohailhl @ shuohailhl-PC/cygdrive/d $ echo $ aaaaaabcdeshuohailhl @ shuohailhl-PC/cygdrive/d $ A = 'echo 123456789 | tr '1-9' '[A *] 'bcde' # Do not specify the replacement quantity of, shuohailhl @ shuohailhl-PC/cygdrive/d $ echo $ aaaaaabcdeshuohailhl @ shuohailhl-PC/cygdrive/d $ A = 'echo 123456789 | tr '1-9' [A * 6] 'bcde' # specify the number of replacements as 6, then the last E will be out of shuohailhl @ shuohailhl-PC/cygdrive/d $ echo $ aaaaaaabcd