1、* 匹配任何字符串
2、? 匹配任何单个字符
3、[…] 匹配[]中所包含的任何字符
4、[!…] 匹配非感叹号之后的字符
正则表达式关键字符:[^*?+.$]、[\{]、[\}]
echo:
1、-n 输出后不换行
2、-e 使转义字符生效(默认是不会自动转义的)
read:
1、一次读入一个变量时,以行为分隔符
2、一次读入多个变量时,以空格为分隔符
cat:
-n -b 显示行号
重定向操作:
1、2>/dev/null 丢弃stderr
2、2>&1 stderr重定向到stdout
3、command<
shell命令连接:
command1 || command2 1失败,则执行2
command1 && command2 1成功,则执行2
command1 ; command2 ; ... 顺序执行
grep:
grep [options] PATTERN [files...]
风格:字符串用双引号("mystring"),调用变量时也用双引号、变量用“{}”括起来("${MYVAR}"),调用模式匹配时用单引号('\w')。
选项:
1、-c 只输出匹配行数
2、-i 不区分大小写
3、-n 显示匹配的行号
4、-v 显示不匹配的所有行
5、-E 扩展模式,扩展正则表达式($grep -E 'add|sub' filename)
查询多个文件:$grep "main" *.c
awk:
1、FS 默认为空隔符 => OFS => NF
2、RS 默认为换行符 => ORS => NR
3、各个域的值为$1 - $NF,$0为记录的值
4、比较[~]、[!~]匹配不匹配
5、内置字符串函数:
gsub(r,s)
gsub(r,s,t) 整个t中用s替代r
index(s,t) t中找s
length(s)
match(s,r)
split(s,a,fs)
sprint(fmt,exp)
sub(r,s)
substr(s,p)
substr(s,p,n) 返回s中从p开始长度为n的后缀部分
sed:
1、模式:[1,9]、[/START/,/END/]
2、动作:[= p s d rw gh]
3、修改:\i \a \c
commands:
whois whereis
whatis apropos
iconv 编码转换
head tail more less
find sort tr
stty 设置终端属性

