【文件属性】:
文件名称:test命令-UNIX初级教程
文件大小:1.01MB
文件格式:PPT
更新时间:2021-04-22 18:40:27
UNIX
test命令
test命令:shell内部命令,检测参数中的条件表达式的真假。如真返回0 ,否则返回非0。
方括号[ ] 是 test 的特殊形式。注意,如同test 命令一样,[ ]与各项及各项之间必须加空格。
例15:test 检测字符串
$ cat test.exam
echo “ Are you OK? “
echo –e “ Input Y for yes or N for no:\c “
read answer
if test “ $answer “ = Y
then
echo “ Glad to hear that”
else
echo “ Go home ”
fi
$