- 论坛徽章:
- 0
|
- #!/bin/sh
- filepath=/home/creat/
- file=aaa
- start_string=333
- end_string=777
- cd filepath
- test=`cat aaa|grep $start_string`
- if [ -n "$test" ];then
- start_array=(`sed "/${start_string}/=" -n $file`)
- start=${start_array[@]:0:1}
- else
- start=`sed -n '$=' $file`
- fi
- test=`cat aaa|grep $start_string`
- if [ -n "$test" ];then
- end_array=(`sed "/${end_string}/=" -n $file`)
- end=${end_array[${#end_array[*]}-1]}
- else
- end=`sed -n '$=' $file`
- fi
- line=`sed -n '$=' $file`
- echo $start
- echo $end
- echo $line
- if [ $start -eq $line ];then
- exit 1
- elif [ $start -eq $end ];then
- exit 2
- elif [ $end -lt $start ];then
- exit 3
- elif [ $end -lt $line ];then
- if [ $start -lt $end ];then
- sed -i "/${start_string}/,/${end_string}/d" $file
- fi
- elif [ $end -eq $line ];then
- test=`sed -n "${line}p" $file|grep $end_string|awk '{print $1}'`
- if [ -n "$test" ];then
- echo $test
- sed -i "/${start_string}/,/${end_string}/d" $file
- exit 4
- fi
- else
- exit 5
- fi
复制代码 |
|