sed
s:字符替换
sed ‘s///’ file
sed ‘s/abc.net/efg.com/’ test.txt
c:整行替换
sed ‘//c/’ file
sed ‘/^SELINUX/cSELINUX=disabled/’ /etc/selinux/config
g:全局替换
sed ‘s///’ file
sed ‘s/abc.net/efg.com/’ test.txt
-n:定位到某一行
sed -n ‘2p’ (后跟文件如:t.txt) 定位到第二行
sed -n ‘/broadcast/p’ (后跟文件如:t.txt)定位到有broadcast这一行
-e:允许在同一行命令中执行多个指令
sed -e ‘///’ -e ‘///’
sed -e ‘s/11/AA/’ -e ‘s/bb/GG/’ ss.txt
-i:生效到文本;否则只是屏显测试结果
sed可以同时对多个文件执行同一个’操作 ’
sed ‘s/11/AA/’ ss.txt SS.txt
awk:报告生成器(不修改文本)
行:record
列:field
NR:number of record
NF:number of field
awk ‘{print $1}’ access.log $1指第一列
awk ‘{print $NF}’ access.log
awk ‘{print $NF-1}’ access.log
awk ‘{print $(NF-1)}’ access.log