|
发表于 2004-12-8 23:21:11
|
显示全部楼层
cat ${1} | egrep -c -i "GM1"
$1指的是程序运行时所带的第一个参数,例如:源程序叫做program,要查找的那个文本文件叫datafile,运行程序./program datafile,datafile就作为了源程序里的$1($2等依次类推,$0为源程序名)。
那么 cat $1 就是print out the content of datafile to the standard output, which is screen,egrep -c -i "GM1" 的作用就是逐行计算文件里GM1的个数
-c, --count
Suppress normal output; instead print a count of matching lines
for each input file. With the -v, --invert-match option (see
below), count non-matching lines.
-i, --ignore-case ignore case distinctions
cat ${1} | egrep -c -i "GM1" 得到的结果就是datafile里GM1的个数
if [ `cat ${1} | egrep -c -i "GM1"` -gt 0 ]
-gt 0 是指值是否大于0
`cat ${1} | egrep -c -i "GM1"` -gt 0 作用就是判断datafile里是否含有GM1,有则进行
cat ${1} | sed 's:GM1_c*:/_at_dom_GM12/object/GM1_c:g' > ${1}
把所有GM1_c?替换成/_at_dom_GM12/object/GM1_c
第一次写这么多,不知道讲清楚没有,有什么疏漏或不对之处还望包含 |
|