我想让用户键入选项 1-3,然后保存,然后与 .txt 文件中的其他输入一起。我试过使用 switch 但它似乎不起作用.. 只有 bash prog 的初学者..
echo "Select the Employee Type:"
echo "1- Salaried Employee"
echo "2- Hourly Employee"
echo "3- Commission Employee"
echo -en "Enter Selection: "
read choice
case $choice in
"1")
Type="Salaried Employee"
break
;;
"2")
Type = "Hourly Employee"
break
;;
"3")
Type ="Commission Employee"
break
;;
*) echo "Error: Please enter a choice between 1 - 7"
echo -en "Hit [Enter] to return..."
read
;;
esac
`if [ `count_lines "^${Name},"` -ne 0 ]
then
echo "Error: Entry already exist!!"
else
confirm "Are you sure you want to add the entry?[y/n]"
if [ $? -ne 0 ]
then
echo "Previous entry not updated!"
else
echo "Record is updated with new employee!!"
echo "${Name},${Job},${Department},${Salary},${Type}" >> $PAYROLL
fi
fi`