随笔分类 -  shell编程

摘要:grep "str" file > /dev/null if [ $? -eq 1]; then echo "no str" else echo "find str" fi 输出到/dev/null中为了不打印输出 阅读全文
posted @ 2017-01-17 09:52 chencesc 阅读(119) 评论(0) 推荐(0)
摘要:匹配 sed -n '/pattern/p' file_name |sed -n 7,12p #pattern是你要查的内容 #file_name是你要查的文件 以上实现:打印出匹配结果中的7-12行 sed -n '/pattern/{7,12p}' file_name 以上实现将文件中7到12行 阅读全文
posted @ 2017-01-16 13:00 chencesc 阅读(122) 评论(0) 推荐(0)
摘要:每行操作 cat 1.log|while read line; do NAME=`awk 'BEGIN {split("'"$line"'",arr);print arr[1]}'` ID=`awk 'BEGIN {split("'"$line"'",arr);print arr[2]}'` don 阅读全文
posted @ 2017-01-15 19:00 chencesc 阅读(111) 评论(0) 推荐(0)
摘要:http://blog.csdn.net/yuguiyang1990/article/details/40400271 阅读全文
posted @ 2017-01-15 17:35 chencesc 阅读(116) 评论(0) 推荐(0)
摘要:1.正则表达式中的符号:http://www.cnblogs.com/yirlin/archive/2006/04/12/373222.htmlhttp://vbird.dic.ksu.edu.tw/linux_basic/0330regularex.php#lang 一.匹配[bjp]匹配集合中的... 阅读全文
posted @ 2015-12-01 12:52 chencesc 阅读(147) 评论(0) 推荐(0)
摘要:一.shift 参数左移 until [ $# -eq 0 ]doecho "第一个参数为: $1 参数个数为: $#"shiftdone 二.wc 该命令用于统计指定文件中的字节数、字数、行数。该命令各选项含义如下: -l 统计行数 -w 统计字数 -c 统计字节数 这些选项可以组合使用。输出列的 阅读全文
posted @ 2015-11-27 16:11 chencesc 阅读(198) 评论(0) 推荐(0)
摘要:1. 定义 :func() {}或function func() {}2.参数func 1 2 3 4 可在函数中直接调$1来使用,>=10的用${n} 阅读全文
posted @ 2015-11-27 15:30 chencesc 阅读(134) 评论(0) 推荐(0)
摘要:一.if语句 if [expression] then elif[expression] then else fi 注 : expression前后要有空格;判断相等用 = 而不是 == ; then可以另起一行,也可以与if同行,同行时要加';'; http://lxsym.blog.51cto. 阅读全文
posted @ 2015-11-27 14:19 chencesc 阅读(307) 评论(0) 推荐(0)
摘要:字符串 : 1.单引号: str = 'value'单引号字符串的限制: 单引号里的任何字符都会原样输出,单引号字符串中的变量是无效的; 单引号字串中不能出现单引号(对单引号使用转义符后也不行);2.双引号: str = "value is \"${name}\" \n" str = "valu... 阅读全文
posted @ 2015-11-27 13:25 chencesc 阅读(238) 评论(0) 推荐(0)
摘要: 阅读全文
posted @ 2015-11-27 13:06 chencesc 阅读(141) 评论(0) 推荐(0)
摘要:http://c.biancheng.net/cpp/view/2739.html1.定义 : 直接定义 value="hi"注:等号前后不能加空格2.使用 : 加美元符号your_name="cesc"echo $your_nameecho ${your_name} 推荐给所有变量加上花括号,... 阅读全文
posted @ 2015-11-27 11:01 chencesc 阅读(168) 评论(0) 推荐(0)