1、杀死某关键词进程,启动服务进程为后台运行模式
count=`ps -ef |grep keywords |grep -v "grep" |wc -l` echo $count if [ 0 == $count ];then echo 'no process' else ps -ef|grep keywords |grep -v grep|cut -c 9-15|xargs kill -9 fi nohup ./keywords >/dev/null 2>&1 &
2、查询内存占用最高的4个进程
ps -aux |sort -rnk 4|head -n 5
ps -eo pid,tty,user,comm,lstart,etime | grep init
参数说明:
pid:进程ID
tty:终端
user:用户
comm:进程名
lstart:开始时间
etime:运行时间
4、查看文件夹下是否有大于1M的txt文件并排序输出
#先通过查看是否有大于1M的txt文件,没有的话就不用继续了 find . -name '*.txt' -size +1M -type f #若有 find . -name '*.txt' -size +1M -type f -print0|xargs -0 du -m|sort -nr|head -10
#vim操作
全选(高亮显示):按esc后,然后ggvG或者ggVG
全部复制:按esc后,然后ggyG
全部删除:按esc后,然后dG
5、查找一个大文件中的某个限定字符
cat rules_domain.csv | grep "^t.cn" | more