shell基础
wssjn1994
这个作者很懒,什么都没留下…
展开
-
shell基本语法总结
shell文件开始要写#/bin/sh或#/bin/bash 但由于是两种不同的解释方法所以语法可能有差异,我选择了前者 1.字符串拼接,得到字符串长度,注意变量的赋值操作等号两侧不能加空格 #/bin/sh str="abc" getstr="${str}def" echo $getstr echo ${#getstr} 2.字符串中查找字符 #/bin/sh str=...原创 2018-12-28 16:24:08 · 178 阅读 · 3 评论 -
awk字符处理指令
首先创建一个log.txt文件,内容如下,供测试使用 2 this is a test 3 Are you like awk This's a test 10 There are orange,apple,mongo 1.找出该文件每行的第一个字符串和第三个字符串,并输出 awk '{print $1,$3}' log.txt $1和$3代表每行的第一个字符串和第三个字符串,...原创 2018-12-29 15:30:09 · 304 阅读 · 0 评论 -
linux用脚本杀死已知名字的进程
sp_pid=`ps -ef | grep sp-tomcat | grep -v grep | awk '{print $2}'` if [ -z "$sp_pid" ]; then echo "[ not find sp-tomcat pid ]" else echo "find result: $sp_pid " kill -9 $sp_pid 注意:使用时,需要把第一行的 sp-...转载 2019-03-12 20:10:18 · 311 阅读 · 1 评论