脚本练习_当用户输入值为数字时显示 非数字时不显示 输入 end 时退出

#!/bin/bash

## Script Filename : print_test.sh.
## Writen by Wangxiaoqiang 2014/12/17.

while :;do
  read -p "Please input a number : " number
  [ "$number" == "end" -o "$number" == "END" -o "$number" == "End" ] && break
  key=`echo ${number} | grep -Po '[\d]+'`
  [ -z "$key" ] || [ "$key" != "$number" ] && continue || echo $key ; continue
done



你可能感兴趣的:(Scripts)