}
while [ $CHOICE!=''Q'' ]; do
case $CHOICE in
1) select_line 1 ;;
2) select_line 2 ;;
3) select_line 3 ;;
Q) exit 0 ;;
esac
read -p "Your choice(''Q'' for quit):" CHOICE
done
wait
rm -f $TMP1
十三、压缩文件
mycompress() {
case $1 in
''gzip'') gzip ic $2 > ${2}.gz ;;
''bzip2'') bzip2 -k $2 ;;
''zip'') zip ${2}.zip $2 ;;
*) echo "Wrong Compress format." ; exit 1 ;;
esac
}
while getopts ":c:" SWITCH; do
case $SWITCH in
''c'')
CTOOL=$OPTARG ;;
?)
echo "Wrong Option"
echo "^[[31mUsage:^[[0m `basename $0` -c zip|gzip|bzip2 file_name"
esac
done
十七、ping B、C类网
cping() {
PINGNET=`echo $1 |sed ''s/([0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}).*/1/g''`
let I=1
while [ $I -le 20 ]; do
ping -c1 -W1 $PINGNET.$I &> /dev/null
[ $? -eq 0 ] && echo "$PINGNET.$I online." || echo "$PINGNET.$I offline."
let I
done
}
bping() {
BPINGNET=`echo $1 | sed ''s/([0-9]{1,3}.[0-9]{1,3})..*/1/g''`
let K=0
while [ $K -le 254 ]; do
cping $BPINGNET.$K
let K
done
}
read -p ''A network:'' MYNET
bping $MYNET
本文出自 “NEGIUP” 博客,请务必保留此出处http://negiup.blog.51cto.com/2348622/461881
|