[root@ppp_m_db zookeeper]# grep "info"*.xml //其中info为关键字,*.xml为正则匹配的文件
build.xml:this work for additional information regarding copyright ownership.
build.xml:<target name="version-info" depends="ver-gen,svn-revision">
ivy.xml:<info organisation="org.apache.zookeeper"
ivy.xml:</info>
grep 'partial\[true\]' abc.log
grep -o 'engine\[[0-9a-z]*\]'//根据符合的正则表达式过滤
grep -v 'grep'//用于过滤
文件内容统计指令awk
[root@ppp_m_db base]# awk '{print $1,$2,$3}' upload.txt
#Serial,Station Name, Station
1, B1,79607S999,1, B2,79607S999,[root@ppp_m_db base]# awk '$1=="1," && $2=="B1,"{print $0}' upload.txt //$0 代表整行输出1, B1,79607S999,1,1,0, Accra,6348271.20424,-23773.65458,614706.82835,359.78543,5.56774,69.922,2018-02-2018:02:13, BFN15483187, NOV OEM6, OEM060620SN0033, NOV703GGG.R2,70.00, BDSTAR-RX
[root@ppp_m_db base]# awk '($1=="1," && $2=="B1,") || NR==1{print $0}' upload.txt //NR==1 为携带表头
#Serial,Station Name, Station Number, State, Clock Use,Iono Use, Station Description, Station ECRF X(m), Station ECRF Y(m), Station ECRF Z(m), Station Earth L(d), Station Earth B(d), Station Earth H(m), Station Vary UTC, Station Rcv Number, Station Rcv Type, Station Rcv Soft Version, Station Rcv Antan Type, Antan Cable Length, Station Belongto
1, B1,79607S999,1,1,0, Accra,6348271.20424,-23773.65458,614706.82835,359.78543,5.56774,69.922,2018-02-2018:02:13, BFN15483187, NOV OEM6, OEM060620SN0033, NOV703GGG.R2,70.00, BDSTAR-RX
[root@ppp_m_db base]# awk -F ","'{print $2}' upload.txt //以逗号,为分隔符,输出第二列
Station Name
B1
B2
//利用awk进行数据统计
awk '{enginner[$1]++}END{for(i in enginner)print i "\t" enginner[i]}'
Sed 指令对文件内容进行批量替换
[root@ppp_m_db base]# sed 's/^Str/String/' upload.txt //此命令只可将替换结果写入控制台
String a ="The beautiful girl's boy friend is Jack".
String b ="The beautiful girl's with and is Jack".
String c ="The beautiful gril love Jack so match".[root@ppp_m_db base]# sed -i 's/^Str/String/' upload.txt //加入-i参数可以加替换结果写入文件[root@ppp_m_db base]# sed -i 's/\.$/\;/' upload.txt //将全文末尾的.替换成;[root@ppp_m_db base]# sed -i 's/Jack/me/g' upload.txt //加入参数-g代表全文替换,要不默认为只替换本行第一次匹配的结果[root@ppp_m_db base]# sed -i '/^ *$/d' upload.txt //删除文中的空行[root@ppp_m_db base]# sed -i '/Integer/d' upload.txt //删除文中的指定行