tr
Tr is used to delete controll characters and substance characters from standard input file.There are two strings, one indicates query conditions, and anther is used to translate between characters. When using tr, the first string is imaged to the second string, and then begin to translate.
syntax: tr -c -d -s [*string1_to_translate_from*] [string2_to_] file
-c : use the other character set except for itself in ASCII to substance the original.
-d : delete all the character existing in the first string
-s : delete all the duplicate character, and only keep the unique character.
1. delete duplicate lines:
# vi oops.txt
Baaarcelona vvs Chellseaa
# tr -s “[a-z]” oops.txt
Barcelona vs Chelsea
2. delete null lines.
# tr -s “[
分类: 科技