摘自Advanced Bash-Scripting Guide V6.0.05 第部分第三章的特殊字符 中的片断,并做了翻译。
- Ctl-A 将光标移到行首
- Ctl-B 退格键(但是我在ubuntu 9.10 bash 3.2.48上测试却是向前移动光标,并不删除该字符)
- Ctl-C 中断 . 中断一个前台任务
- Ctl-D 从当前shell退出(类似exit)EOF (end-of-file). 它也能中断在stdin的输入。
当在一个终端(console)或者虚拟终端(比如xterm)里敲键盘时,ctl-D 会删除当前光标下的字符.如果当前没有任何字符了,则 Ctl-D 表示从当前会话退出,如果时xterm之类的窗口,则会关闭当前窗口。
- Ctl-E 移动光标到行末
- Ctl-F 光标朝前移动一个字符位置
- Ctl-G 响铃(BEL) .在一些老式的电传(teletype)终端里,它可能真的会导致电话铃响起,而在xterm之类的终端里,只是发出一个声响。
- Ctl-H 相当于退格键
#!/bin/bash
# Embedding Ctl-H in a string.
a ="^H^H" # Two Ctl-H's -- backspaces
# ctl-V ctl-H, using vi/vim
echo "abcdef" # abcdef
echo
echo -n "abcdef$a " # abcd f
# Space at end ^ ^ Backspaces twice.
echo
echo -n "abcdef$a " # abcdef
# No space at end ^ Doesn't backspace (why?).
# Results may not be quite as expected.
echo ; echo
# Constantin Hagemeier suggests trying:
# a=$'/010/010'
# a=$'/b/b'
# a=$'/x08/x08'
# But, this does not change the results. - Ctl-I 水平tab键 .
- Ctl-J 新行 (换行符).脚本里,也可能当八进制’/012′或十六进制符号’/x0a’解释。
- Ctl-K 垂直tab 当在console或者xterm窗口里键入文本时, Ctl-K 表示删除从当前光标到行末的字符。在脚本里, Ctl-K 的行为表现就不同的,具体的可以看下面 Lee Lee Maschmeyer的例子。
- Ctl-L 换页 (终端清屏)。在终端里,其效果和clear 命令类似(区别在于当前光标所在的行并不会清除) 。发送到打印机的话,Ctl-L 导致提前结束纸张。
- Ctl-M 回车 .
#!/bin/bash
# Thank you, Lee Maschmeyer, for this example.
read -n 1 -s -p /
$'Control-M leaves cursor at beginning of this line. Press Enter. /x0d'
# Of course, '0d' is the hex equivalent of Control-M.
echo & gt;& amp;2 # The '-s' makes anything typed silent,
#+ so it is necessary to go to new line explicitly.
read -n 1 -s -p $'Control-J leaves cursor on next line. /x0a'
# '0a' is the hex equivalent of Control-J, linefeed.
echo & gt;& amp;2
###
read -n 1 -s -p $'And Control-K/x0bgoes straight down.'
echo & gt;& amp;2 # Control-K is vertical tab.
# A better example of the effect of a vertical tab is:
var =$'/x0aThis is the bottom line/x0bThis is the top line/x0a'
echo "$var "
# This works the same way as the above example. However:
echo "$var " | col
# This causes the right end of the line to be higher than the left end.
# It also explains why we started and ended with a line feed --
#+ to avoid a garbled screen.
# As Lee Maschmeyer explains:
# --------------------------
# In the [first vertical tab example] . . . the vertical tab
#+ makes the printing go straight down without a carriage return.
# This is true only on devices, such as the Linux console,
#+ that can't go "backward."
# The real purpose of VT is to go straight UP, not down.
# It can be used to print superscripts on a printer.
# The col utility can be used to emulate the proper behavior of VT.
exit 0 - Ctl-N 从history 指令缓冲里删除一行可重新调用的文本
- Ctl-O 发出一个新行
- Ctl-P 重新调用history 指令缓冲区调用最后一条指令
- Ctl-Q 恢复(XON )恢复终端的标准输入(stdin)
- Ctl-R 向后搜索history 指令缓冲文本
- Ctl-S 暂停 (XOFF ).冻结终端的标准输入(用ctl-Q来恢复)
- Ctl-T 将当前光标位置的字符和光标前的字符进行位置交换
- Ctl-U 删除从行首到当前光标位置的字符(不包括当前光标位置的字符).在默写设置下, Ctl-U 删除整行,而不管光标位置
- Ctl-V 输入文本的时候, Ctl-V 允许插入控制字符,下面例子的两条指令效果是相同的
echo -e '/x0a'
echoCtl-V 主要在文本编辑器里起作用
- Ctl-W 在终端(console)或者类似xterm窗口里输入文本时, Ctl-W 删除从当前光标位置到之前的第一个空格之间的字符。在某些设置下, Ctl-W 向后删除到第一个非字母数字字符
- Ctl-Z 暂停前台任务