shell中的计算
# cat expr.sh#!/bin/bash
while true
do
read -p "Pls input :" a
expr $a + 0 > /dev/null 2>&1
[ $? -eq 0 ] && echo int || echo chars
done
# sh expr.sh
Pls input :2
int
Pls input :3
int
Pls input :a
chars
Pls input :i
chars
Pls input :>
chars
Pls input :
页:
[1]