Bash是一个sh兼容的命令语言解释器,执行标准输入或文件中的命令。Bash还包含了ksh和csh的有用功能。Bash最终旨在成为IEEE Standard 1003.2的一致性实现。
终端下的提示功能在Bash Completion软件包中。
输入特殊字符
比如输入一个TAB键,但是Bash中TAB用于补全提示。。。
先按下Ctrl+V,然后在按下TAB键。
当BASH无响应时
使用Ctrl+J组合键;或者输入reset内建命令;
在命令提示符号中显示当前GIT分支
「Display git branch in bash prompt」
# 方法一: export PS1="\\w\$(__git_ps1 '(%s)') \$ " # 方法二: parse_git_branch() { git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/' } export PS1="\u@\h \[\033[32m\]\w\[\033[33m\]\$(parse_git_branch)\[\033[00m\]\n$ " # 注意事项: # 1. 不管使用那种方法都要注意“\$”的存在,这用于防止命令被提前执行。否则,当切换到其他目 # 时,分支名不会发生改变。
修改运行进程的输出
「redirecting output of running background job in bash」
「How to redirect output of an already running process」
删除指定目录以外的目录
「Remove all files except some from a directory」
shopt -s extglob
rm !(textfile.txt|backup.tar.gz|script.php|database.sql|info.txt)
相关书籍
《Linux Shell脚本攻略(第2版)》
参考文献
GNU Bash manual:https://www.gnu.org/software/bash/manual/bash.html
怎样写出规范的shell脚本(仅限Scripting with style)
https://www.tutorialspoint.com/unix/case-esac-statement.htm
Bash Reference Manual