【求助】怎么表示只能输入“字母和空格”

【求助】怎么表示只能输入“字母和空格”

有个程序

echo -e "Last Name: \c"
read lastname
case $lastname in
输入字母和空格)echo -e "valid"
*) echo -e "invalid"
esac

问“输入字母和空格”在程序中该怎么写?谢谢。。。。:confused:      
用 grep 进行判断      
#!/bin/bash
echo -e "Last Name:"
read lastname
ok=""
ok=$(echo $lastname|grep '[0-9]' )
if [ -z "$ok" ]
then
   echo "Valid"
else
   echo "Invalid"
fi      
#!/bin/bash
echo -e "Last Name:"
read lastname
ok=""
ok=$(echo $lastname|grep '[^a-zA-Z]' )
if [ -z "$ok" ]
then
echo "Valid"
else
echo "Invalid"
fi