ITeye博客

鸟哥私房菜1-第11章:认识Bash Shell

1804 · 2011-11-10 00:43 · Unix Linux · 操作系统 · Markdown

鸟哥私房菜1-第11章:认识Bash Shell read declare/typeset array ulimit user limit echo ${vbird##//} 删除所有//之间数据 echo ${vbird#//} 删除第一个//之间数据 echo ${vbird%%//} 从后面删除所有//之间数据 这样匹配,需要最后一个字符是/ echo ${vbird%%/} 从后面删除所有/之间数据 echo ${vbird%/} 从后面删除第一个有/*之间数据 echo ${vbird/testing/TEST} 用TEST替换testing(仅仅第一个) echo ${vbird//testing/TEST} 用TEST替换testing(所有) 类似的操作符有 -/:-/+/:+/=/:=/?/:? 规则感觉比较奇怪 alias / unalias

history ~/.bash_history !number 执行第几条命令 !command 最近命令往前搜索“命令行开头是command”的命令,并执行 !! 执行上一个命令

登陆消息显示数据: /etc/issue,/etc/motd 环境设置文件: bashrc, ~/.bashrc, ~./profile, profile..., /etc/inputtrc, source /etc/sysconfg/i18n /etc/profile /etc/bashrc /etc/profile.d/*sh /etc/man.config ~/.bash_profile, ~/.bash_login, ~/.profile ~/.bashrc ~/.bash_history ~/.bash_logout 登陆文件的读取 /etc/profile -> /etc/profile.d, /etc/inputtrc -> ~/.bash_profile,

~/.bash_login, ~/.profile -> ~/.bashrc

登陆shell,读取 ~/.bash_profile, ~/.bash_login, ~/.profile 非登陆shell,仅仅读取 ~/.bashrc

stty, set stty erase ^C

Ctrl + D 输入结束 Ctrl + S 暂停屏幕输出 Ctrl + Q 回复屏幕输出 Ctrl + Z 暂停当前命令 Ctrl + C 终止当前命令

数据流重导向 标准输入,代码0,<, << 标准输出,代码1, >, >> 标准错误输出,代码2,2>, 2>> /dev/null 错误 find /home -name testing > list.txt 2> list.txt 正确 find /home -name testing > list.txt 2> &1 cat > cat_output.txt < cat_input.txt cat > cat_output.txt << eof 命令执行的判断根据: ;, &&, || sync; sync; shutdown -h now ls /tmp && touch /tmp/testingagain ls /tmp/vbird || touch /tmp/vbird

管道命令 管道命令"|"只能处理通过前面一个命令传来的正确信息,也就是标准输出信息,对标准错

误,并没有直接处理的能力 选取命令 cut, grep 排序命令 sort, wc, uniq wc 计算文件内容的工具 双向重导向 tee 能同时输出到2个地方,可以能既输出到屏幕,又输出到文件 默认情况下,如果输出到文件,就不能输出到屏幕了 字符转换命令 tr, col, join, paste, expand tr 删除一段消息中的文字,或者进行文字替换 last | tr '' '' 将所有小写字母转成大写字母 col 将tab键转换成对等的空格键 join 处理2个文件时,有相同数据行,将他们加在一起

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。