我想让用户在选择1-3中键入,然后保存,然后与其他输入一起保存在.txt文件中。我一直在使用开关尝试,但它似乎并没有工作.. 只有在bash PROG初学者..bash脚本。如何将用户的选择添加到txt文件
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`
assigments在脚本中的'人物真的存在,还是你只是将它们添加到尽量做到#2正确显示? –
请给我们一个简单但完整的脚本。您定义了一些未在脚本中定义的变量(** $ Name **,** $ Job **,...)和函数(** count_lines **)。我不明白具体问题... – EverythingRightPlace
其他变量正在工作,直到我添加了最后一个“EMployee类型” – Alien