| |
shell脚本:shell命令 & shell流程控制语句 & 注释语句
1. "#" 用于注释
2. 第一行中,以"#!"开头,它通知系统脚本可执行。"#!"之后可接上shell的名字(csh,sh等)或执行脚本的程序名,一般是绝对路径。
eg. 对于c shell, " #! /bin/csh/ -f",-f表示快速执行。
3. 写完脚本后,需要改变文件权限,使其可执行: chmod u+x script or chmod 100 script。
4. tee 命令:读取标准输入的数据,并将其内容输出成文件。
tee [-ai] [--help] [--version] [file ...]
eg. cat players.story | tee copy 显示players.story的内容并复制到copy。
eg qrsh dc_shell-t -f vgip2fifo.tcl | tee log (用> log不能打印出信息)
5. grep:从一个或者多个文件中过滤出具有某个字符的行。
eg. cat *.txt | grep lint 显示*.txt中含lint的行。