我想讓用戶在選擇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