TR (abbreviated by Traslate) can be used to delete text from a piece of information, or to replace text messages!
[Email protected] ~]#TR[-DS] SET1 ... Options and Parameters:-d: Delete the SET1 string from the message;-s: replace the duplicate characters! Example one: to Lastin the output information, all lowercase letters become uppercase characters: [[email protected]~]# Last|TR '[A-z]' '[A-z]'# In fact, there is no single quote that can be run, such as: " Last|TR[A-z] AZ] "Example two: Will/etc/passwdin the output information, the colon (:) delete [[email protected]~]#Cat/etc/passwd|TR-D':'example three: the/etc/passwdDump DOS to/root/passwd, and then the ^M sign Delete [[email protected]~]#CP/etc/passwd/root/passwd&& unix2dos/root/passwd[[Email protected]~]#file/etc/passwd/root/passwd/etc/passwd: ASCII text/root/passwd: ASCII text, with CRLF line Terminators <==is a DOS break [[email protected]~]#Cat/root/passwd|TR-D'\ r'>/root/passwd. linux# that \ r refers to a DOS-break character, for more characters, refer toMans TR[[Email protected]~]# ll/etc/passwd/root/passwd*-rw-r--r--1Root root1986Feb6 -: -/etc/passwd-rw-r--r--1Root root2030Feb7 the: -/root/passwd-rw-r--r--1Root root1986Feb7 the: $/root/passwd.
in fact, this command can also be written in the "formal notation" inside! Because he is also in the form of formal notation to replace the data! In the example above, use [] to configure a string of words! It's also often used to replace weird symbols in files ! For example, in the third example above, you can remove the ^m of a DOS file! This thing is quite useful! Believe it's the most troublesome thing to do with Linux & Windows systems! That is, the DOS will automatically add the ^m line at the end of each line! This time we can use this TR to remove the ^m! ^m can use \ r to replace it!
References: http://vbird.dic.ksu.edu.tw/linux_basic/0320bash.php#pipe_4