关于linux shell的问题

[复制链接]
查看11 | 回复3 | 2013-8-19 13:09:01 | 显示全部楼层 |阅读模式
假设你说的“字符”指的是字母或数字 (a-z A-Z 0-9),如果不是,可以修改 grep 命令的正则表达式:function check_all_letter{
matchStr=`echo ${1} | grep -o "^[a-zA-Z0-9]*"`
if [ "${matchStr}" == "${1}" ]; then
echo "input correct."
else
echo "error, include inlegal character !"
fi}使用方法例子:read -p "input content: " inputche...
回复

使用道具 举报

千问 | 2013-8-19 13:09:01 | 显示全部楼层
read stringecho $string|egrep '[[:alpha:]]'if $0;thenecho successelseecho failurefi...
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行