![](https://img-blog.csdnimg.cn/20201014180756928.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
shell
轮子上的猫
励志成为伟大程序员的男人
展开
-
编写shell停止程序脚本
example:ps -ef | grep smartv.jar | grep -v grep|awk '{print "kill -9 " $2}' | sh使用:将smartv.jar根据实际情况替换成需要kill的程序解释: grep -v grep:排除grep搜出出的进程; awk $2:截取获得pid号原创 2020-06-03 13:31:31 · 473 阅读 · 0 评论 -
shell 字符串、匹配文本内容
通过 grep 字符串 文件 文件grep stringNmae /etc/hosts写一个小demo:判断用户是在/etc/hosts 中配置主机名,如果没有配置则配置主机名#!/bin/shhostPath=/etc/hostsname=`hostname`hostContent=`grep ${name} ${hostPath}`if [ $? -eq 0 ]th...原创 2019-07-03 18:12:11 · 5238 阅读 · 0 评论 -
shell 在已有文件中追加多行内容
通过 cat>>文件<<EOF EOF 来实现文件追加多行内容ex:执行cat >>/test/appendLine.conf<<EOF我是第二行我是第三行EOF显示结果为:原创 2019-07-03 18:33:02 · 15312 阅读 · 0 评论