我需要验证输入并根据条件为true或false接收有效输出。即使我的条件成立,我仍然得到错误的输出。我的代码在哪里错了?
#
set input
#read -p "Who wrote the book Roots?" : input
#echo Who wrote the book Roots?
#read input
if($input == "Alex Haley")
echo "bla bla"
else
echo "bla bla bla"
endif
我评论了用于获取信息的方法,两者都不起作用。
read -p input
,给我:
read [9]: read: no query process
答案 0 :(得分:1)
echo -n "Enter author: "
set input = "$<"
if ("$input" == "Alex Haley") then
echo "bla bla"
else
echo "bla bla bla"
endif
USAGE
> csh test.csh
Enter author: Alex Haley
bla bla
> csh test.csh
Enter author: Mark Twain
bla bla bla
>