摘自:http://blog.51cto.com/lynnteng0/804520describe="it's a describe by yourself" if echo "$describe" | grep -q '^[a-zA-Z0-9]\+$'; then echo "ok" else echo "invalid" fi describe="it's a describe by yourself" if echo "$describe" | grep -q '[^a-zA-Z0-9]'; then echo "invalid" fi