控制字符知识普及


ASCII字符集的定义128个字符(0 to 127),前32个值非打印控制字符(0-31以及127),例如^G 7 表示bell(响铃)。


控制字符:

Char

八进制十进制十六进制Control-KeyControl Action
NUL000^@Null character
SOH111^AStart of heading, = console interrupt
STX222^BStart of text, maintenance mode on HP console
ETX333^CEnd of text
EOT444^DEnd of transmission, not the same as ETB
ENQ555^EEnquiry, goes with ACK; old HP flow control
ACK666^FAcknowledge, clears ENQ logon hand
BEL777^GBell, rings the bell...
BS1088^HBackspace, works on HP terminals/computers
HT1199^IHorizontal tab, move to next tab stop
LF1210a^JLine Feed
VT1311b^KVertical tab
FF1412c^LForm Feed, page eject
CR1513d^MCarriage Return
SO1614e^NShift Out, alternate character set
SI1715f^OShift In, resume defaultn character set
DLE201610^PData link escape
DC1211711^QXON, with XOFF to pause listings; ":okay to send".
DC2221812^RDevice control 2, block-mode flow control
DC3231913^SXOFF, with XON is TERM=18 flow control
DC4242014^TDevice control 4
NAK252115^UNegative acknowledge
SYN262216^VSynchronous idle
ETB272317^WEnd transmission block, not the same as EOT
CAN302417^XCancel line, MPE echoes !!!
EM312519^YEnd of medium, Control-Y interrupt
SUB32261a^ZSubstitute
ESC33271b^[Escape, next character is not echoed
FS34281c^\File separator
GS35291d^]Group separator
RS36301e^^Record separator, block-mode terminator
US37311f^_Unit separator


打印字符

CharOctalDecHexDescription
SP403220Space
!413321Exclamation mark
"423422Quotation mark (" in HTML)
#433523Cross hatch (number sign)
$443624Dollar sign
%453725Percent sign
&463826Ampersand
`473927Closing single quote (apostrophe)
(504028Opening parentheses
)514129Closing parentheses
*52422aAsterisk (star, multiply)
+53432bPlus
,54442cComma
-55452dHyphen, dash, minus
.56462ePeriod
/57472fSlant (forward slash, divide)
0604830Zero
1614931One
2625032Two
3635133Three
4645234Four
5655335Five
6665436Six
7675537Seven
8705638Eight
9715739Nine
:72583aColon
;73593bSemicolon
<74603cLess than sign (&lt; in HTML)
=75613dEquals sign
>76623eGreater than sign (&gt; in HTML)
?77633fQuestion mark
@1006440At-sign
A1016541Uppercase A
B1026642Uppercase B
C1036743Uppercase C
D1046844Uppercase D
E1056945Uppercase E
F1067046Uppercase F
G1077147Uppercase G
H1107248Uppercase H
I1117349Uppercase I
J112744aUppercase J
K113754bUppercase K
L114764cUppercase L
M115774dUppercase M
N116784eUppercase N
O117794fUppercase O
P1208050Uppercase P
Q1218151Uppercase Q
R1228252Uppercase R
S1238353Uppercase S
T1248454Uppercase T
U1258555Uppercase U
V1268656Uppercase V
W1278757Uppercase W
X1308858Uppercase X
Y1318959Uppercase Y
Z132905aUppercase Z
[133915bOpening square bracket
\134925cReverse slant (Backslash)
]135935dClosing square bracket
^136945eCaret (Circumflex)
_137955fUnderscore
`1409660Opening single quote
a1419761Lowercase a
b1429862Lowercase b
c1439963Lowercase c
d14410064Lowercase d
e14510165Lowercase e
f14610266Lowercase f
g14710367Lowercase g
h15010468Lowercase h
i15110569Lowercase i
j1521066aLowercase j
k1531076bLowercase k
l1541086cLowercase l
m1551096dLowercase m
n1561106eLowercase n
o1571116fLowercase o
p16011270Lowercase p
q16111371Lowercase q
r16211472Lowercase r
s16311573Lowercase s
t16411674Lowercase t
u16511775Lowercase u
v16611876Lowercase v
w16711977Lowercase w
x17012078Lowercase x
y17112179Lowercase y
z1721227aLowercase z
{1731237bOpening curly brace
|1741247cVertical line
}1751257dCloing curly brace
~1761267eTilde (approximate)
DEL1771277fDelete (rubout), cross-hatch box

shell中处理控制字符:

有时候文本中会留有控制符,比如test1:

需要用cat -v  或者cat -A 才可以看到控制字符^A

21.703073010384102^A24.714308723165203^A27.38294439629967^A32.307091875806^A76429^A209438

现在需要把^A转换为空格。^A是1(或01、001),空格是40(或040)。重定向到test2。

tr -s "[\001]" "[\040*]" <test1 >test2




  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值