Shell脚本文件操作

Linux Shell 

http://baike.baidu.com/link?url=2LxUhKzlh5xBUgQrS0JEc61xi761nvCS7SHJsa1U1SkVbw3CC869AoUCyKT0zxIM

# Sample.sh
# 判断参数个数和第2/3个参数,括号要留空格
1
if ( [ $# != 5 ] && [ $# != 6 ] ) || ( [ $2 != "-Path" ] && [ $3 != "-Path" ] ) 2 then 3 echo "example: ***" 4 exit 1 5 fi
6 7 if [ $1 == "set" ] && [ $2 == "-pm" ] 8 then
# bash/pdksh不能在等号两侧留下空格
9 PATH=$4
10 else
11 PATH=$3
12 fi
13
# 删除已经存在文件
14
if [ -e $PATH/out.txt ] 15 then 16 rm $PATH/out.txt 17 fi 18
# 调用程序
19
if [ $1 == "set" ] && [ $2 == "-pm" ] 20 then 21 $4/sample.sh $1 $2 -Path $4/config $5 $6 22 else 23 $3/sample.sh $1 -Path $3/config $4 $5 24 fi

 

posted on 2015-11-13 14:37  浩然119  阅读(360)  评论(0编辑  收藏  举报