tr%20[OPTION]...%20SET1%20[SET2]
Translatelinux常用命令,%20squeeze,%20and/or%20delete%20characters%20from%20standard%20input,writing%20to%20standard%20output.
str="hello world"
# hello world
echo ${str}
# AAllAAAAAlA
echo ${str} | tr -c 'll\n' 'A'
# hello-world
echo ${str} | tr -c 'a-z\n' '-'
# hello-world
echo ${str} | tr -C 'a-z\n' '-'
str="hello world"
# hello world
echo ${str}
# helloworld
echo ${str} | tr -d ' '
# he wrd
echo ${str} | tr -d 'llo'
str="thissss is a text linnnnnnne."
# thissss is a text linnnnnnne.
echo ${str}
# this is a text line.
echo ${str} | tr -s ' sn'
str="hello world"
# hello world
echo ${str}
# heaao worad
echo ${str} | tr -t 'l' 'a'
# hello-world
echo ${str} | tr -t ' ' '-'
SETs are specified as strings of characters. Most represent
themselves. Interpreted sequences are:
\NNN character with octal value NNN (1 to 3 octal digits)
\\ backslash
\a audible BEL
\b backspace
\f form feed
\n new line
\r return
\t horizontal tab
\v vertical tab
CHAR1-CHAR2
all characters from CHAR1 to CHAR2 in ascending order
[CHAR*]
in SET2, copies of CHAR until length of SET1
[CHAR*REPEAT]
REPEAT copies of CHAR, REPEAT octal if starting with 0
[:alnum:]
all letters and digits
[:alpha:]
all letters
[:blank:]
all horizontal whitespace
[:cntrl:]
all control characters
[:digit:]
all digits
[:graph:]
all printable characters, not including space
[:lower:]
all lower case letters
[:print:]
all printable characters, including space
[:punct:]
all punctuation characters
[:space:]
all horizontal or vertical whitespace
[:upper:]
all upper case letters
[:xdigit:]
all hexadecimal digits
[=CHAR=]
all characters which are equivalent to CHAR
上一個(gè)教程:getsebool命令詳解
下一個(gè)教程:linux系統(tǒng)上傳和下載文件(命令行)