awk统计文件中某关键词出现次数的命令
网络编程
awk -F "" '{for(i=1;i<=NF;++i) if($i=="a") ++sum}END{print sum}' test.c
[root@xiaobb 5906]# awk '{for(i=1;i<=NF;++i) if($i=="test") ++sum}END{print sum}' test.c
6
[root@xiaobb 5906]# cat test.c
test test
ktest
test
a test
test a
l test
ltest
[root@xiaobb 5906]# awk '{for(i=1;i<=NF;++i) if($i=="test") ++sum}END{print sum}' test.c
6
[root@xiaobb 5906]# cat test.c
test test
ktest
test
a test
test a
l test
ltest
shell 进度条实现代码
#!/bin/bashCOUNTER=0_R=0_C=`tputcols`_PROCEC=`tputcols`tputcup$_C$_Rprintf"["while[$COUNTER-lt100]doCOUNTER=`expr$COUNTER+1`sleep0.1printf"="_R=`expr$_R+1`_C=`expr$_C+1`tputcup$_PROCEC101printf"]%d%%"
一个用了统计CPU 内存 硬盘 使用率的shell脚本
#!/bin/bash#ThisscriptisusefordescribleCPUHardMemeryUtilizationtotal=0idle=0system=0user=0nice=0mem=0vmexec=/usr/bin/vmstatwhichsar/dev/null2&1if[$?-ne0]thenver=`vmstat-V|awk'{printf$3}'`nice=0temp=`v
统计 cpu 内存 使用率的shell脚本代码
#!/bin/shclearwhile((10))doNET=$(netstat-anp|grep1000|grepEST|wc-l)PRC=$(psaux|grepthread1|grep-vgrep|grep-vSCREEN|awk'{print"CPU:"$3"%,MEM:"$4"%,RSS:"$6/1024"M,VSZ:"$5/1024"M,PID:"$2""}')tputsc;echo-
编辑:一起学习网
标签:使用率,脚本,内存,代码,用了