【发布时间】:2015-07-21 10:38:03
【问题描述】:
我一直在为这个问题摸不着头脑......我试图让我的代码做出如下反应:
If no parameters, go to menu
If more OR less than 4 parameters, call error and go to menu
If exactly 4 parameters, write to file and exit
我无法让它以任何方式工作,如果您能提供帮助,将不胜感激!
username=$1
firstname=$2
surname=$3
password=$4
if test "$#" = 0; then
{
menu
}
elif test "$#" = 4; then
{
echo Error
sleep 2
menu
}
else {
echo Done
echo "$firstname" "$surname" >> "$username".log
echo "$password" >> "$username".log
curdate=$(date +'%d/%m/%Y %H:%M:%S')
echo "$curdate" >> "$username".log
sleep 2
clear
exit
}
fi
【问题讨论】:
标签: linux bash command-line command-line-arguments