09 2015 档案

摘要:shell上:0表示标准输入1表示标准输出2表示标准错误输出> 默认为标准输出重定向,与 1> 相同2>&1 意思是把 标准错误输出 重定向到 标准输出.&>file 意思是把 标准输出 和 标准错误输出 都重定向到文件file中用例子说话:1. grep da * 1>&22. rm -f $(f... 阅读全文
posted @ 2015-09-29 15:00 Big_Foot 阅读(447) 评论(0) 推荐(0)
摘要:Shell编程中Shift的用法位置参数可以用shift命令左移。比如shift 3表示原来的$4现在变成$1,原来的$5现在变成$2等等,原来的$1、$2、$3丢弃,$0不移动。不带参数的shift命令相当于shift 1。非常有用的 Unix 命令:shift。我们知道,对于位置变量或命令行参数... 阅读全文
posted @ 2015-09-29 14:15 Big_Foot 阅读(275) 评论(0) 推荐(0)
摘要:(1)数组的定义root@tcx4440-03:~# a=(1 2 3 4)root@tcx4440-03:~# echo ${a[1]}2root@tcx4440-03:~# a[0]=1root@tcx4440-03:~# a[1]=2root@tcx4440-03:~# echo ${a[0]... 阅读全文
posted @ 2015-09-15 16:16 Big_Foot 阅读(677) 评论(0) 推荐(0)
摘要:root@tcx4440-03:~# var=$var+1root@tcx4440-03:~# echo $var3+1要想达到预期结果,用下列三种方法:(1)let "var+=1" (2)var=$[$var+1] (3)var=`expr $var + 1`#注意加号两边的空格,否则还是按照字... 阅读全文
posted @ 2015-09-15 14:34 Big_Foot
摘要:#! /usr/bin/kshcount=$# //总共输入参数cmd="echo"while [[ $count -gt 0 ]]do cmd="$cmd \$$count " count=`expr $count - 1`done eval $cmd 阅读全文
posted @ 2015-09-15 10:51 Big_Foot 阅读(737) 评论(0) 推荐(0)
摘要:(1)root@tcx4440-03:~# value1=/etc/root@tcx4440-03:~# value2=yum.repos.d/root@tcx4440-03:~# value3=${value1}${value2}root@tcx4440-03:~# echo $value3/et... 阅读全文
posted @ 2015-09-15 09:32 Big_Foot 阅读(177) 评论(0) 推荐(0)
摘要:(1)awk中函数substr substr(源字符串,开始索引,长度) 开始索引以0开始示例:awk '{$a=substr($0,0,2);print $a;}' filename 假设文件中为只有一行为abcdefg,则返回结果为ab(2)expr substr 字符串 开始索引 长度 开始索... 阅读全文
posted @ 2015-09-14 16:56 Big_Foot 阅读(9020) 评论(0) 推荐(0)
摘要:${expression}一共有9种使用方法。${parameter:-word},如果parameter为空,则用word的值做parameter的缺省值${parameter:=word},在2 的基础上,把word的值赋值给parameter${parameter:?word},如果param... 阅读全文
posted @ 2015-09-14 16:53 Big_Foot 阅读(679) 评论(0) 推荐(0)