Linux常用命令总结

查看当前系统内核

[root@ppp_m_db bin]# uname
Linux
[root@ppp_m_db bin]# 

文件查找命令find

[root@ppp_m_db bin]# find /ppp/base -name "zkCli.sh"
/ppp/base/zookeeper/bin/zkCli.sh
[root@ppp_m_db bin]# find /ppp/base -iname "zkCli.sh" //忽略大小写
/ppp/base/zookeeper/bin/zkCli.sh
[root@ppp_m_db bin]# find /ppp/base -iname "view*.py"
/ppp/base/zookeeper/src/contrib/huebrowser/zkui/src/zkui/views.py //模糊匹配查询

man find //查看更多find指令说明

文件内容查找指令grep

[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-20 18: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-20 18: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 //删除文中的指定行

查看进程id

[root@ppp_m_db publish]# ps -ef|grep ConfigSystem-1.0-SNAPSHOT.jar|grep -v grep
root      8755     1  1 Jul31 ?        00:12:00 java -jar ConfigSystem-1.0-SNAPSHOT.jar
//ps -ef 查找所有java进程;grep ConfigSystem-1.0-SNAPSHOT.jar 用于模糊查询该ConfigSystem-1.0-SNAPSHOT.jar;grep -v grep 过滤到自身grep进程
//其中8755 便是该进程ID

//可以根据端口号查看进程
[root@ppp_m_db publish]# lsof -i:8988
COMMAND  PID USER   FD   TYPE    DEVICE SIZE/OFF NODE NAME
java    8755 root   38u  IPv6 670658998      0t0  TCP bogon:8988->localhost:58056 (ESTABLISHED)
java    8755 root   40u  IPv6 670587489      0t0  TCP bogon:8988->localhost:58261 (ESTABLISHED)
java    8755 root   47u  IPv6 665496983      0t0  TCP *:8988 (LISTEN)

//其中8755 便为进程ID
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值