RHCE笔记整理-RH033.Unit4-The Bash shell
- Bash :Bourne Again Shell
作用:将用户输入的指令解析成linux kernel能够识别的语言,是用户与系统勾通的桥梁。 - Bash 历史
|--System V:sh--------->Bash
Unix| |
tchsh------------|
zsh
3. File Globbing
- Globbing is wildcard expansion
? matches any single character
[a-z] matches a range of characters
[^a-z] matches all except the range
4. The Tab Key
5. History
Command:history
Usage:
- history命令结果 会输出指令的序号和指令的名称,要使用某一序号的指令,可进行如下操作:!指令序号
- 要修改上一条指令可进行操作:^source^dest
例:#ping 192.168.1.123
#^123^1
则修改后的指令为ping 192.168.1.1
- Back to home directory
$cd ~ - change to other user's home directory
$cd ~username
8. 如何有摊中加入其它指令来显示电脑信息及用指令进行数学运算
- Command output '' or $()
例:$echo "Hostname:`hostname`"
or $echo "Hostname:$(hostname)" - 数学运算:$[]
例:$a=3
$b=5
$c=7
$echo $[$a+$b] //a+b
$echo $[$a**$b] //a的b次方
建议使用时各参数都用空白隔开,这是标准的语法,各平台上都可以使用
- Backslash is the escape character
例:$echo Your cost is $5.00
$Your cost is .00
$echo Your cost is /$5.00
$Your cost is $5.00
- quoting prevents expansion
- Single quotes(`) inhibit all expansion
- Double quotes(") inhibit all expansion except
- $
- /
- `
- !
- use up and down to sroll through previous commands
- type <CTRL-R> to search ro command
- To recall last argument from previous commands:
<esc>. 先按ESC,放开后再按“。”
<Alt-.> 同时按下Alt+.
- By default bsh uses emacs-style
- type "set-o vi" to change keybinding ro vi-style
- set -o 查看电脑上的设定
- 切换编辑模式:
set -o vi 把默认的编辑器改为vi,其中-o表示“减off" 即为“on"
- <ctrl+shift+t> open a new tab
- <ctrl+PgUp/PgDn> Next/Previous tab
- <alt-"N"> change to goto "N" tab
- <ctrl+shift+c/v> copy/paste
- <ctrl+shift+w> close a tab