我将此作为bash脚本的一部分
{
read -n1 -p "Do you want to download some tv programmes? [y/n/q] " ynq ;
[Yy] read -n200 -p "Please input the tv programme numbers to download " 'tvbox';
echo; cd /media/$USER/back2/proggies/; /usr/bin/get-iplayer --get $tvbox;
[Nn]* ) echo;; # moves on to next question in the script
[Qq]* ) echo; exit;; # quits
* ) echo "Thank you ";;
esac
};
但由于语法错误,它无法正常工作。我怎么能让它问两个问题,第二个问题只出现在第一个回答“y”时出现,然后语法错误被解决,以便脚本可以正常工作?感谢。
答案 0 :(得分:2)
case
声明的开头似乎格式不正确。
{
read -n1 -p "Do you want to download some tv programmes? [y/n/q] " ynq
case $ynq in
[Yy]) read -n200 -p "Please input the tv programme numbers to download " 'tvbox'
echo
cd /media/$USER/back2/proggies/
/usr/bin/get-iplayer --get $tvbox
;;
[Nn]* ) echo;; # moves on to next question in the script
[Qq]* ) echo; exit;; # quits
* ) echo "Thank you ";;
esac
};