我收到错误command not found
,不知道出了什么问题。
我认为我的代码存在问题。我需要用户输入付款。
第一个用户输入ID,然后程序将找到具有该ID的人。
然后程序会找到他[雇员或每小时]的雇员类型
然后从那里开始if [$type="Salaried"]
或“Hourly
”代码
提示用户键入相应的数据
请告知我该如何去做?
payroll()
{
line=`grep -i "^${update_empID}," $data`
empID=`echo $line | cut -d "," -f1`
name=`echo $line | cut -d "," -f2`
job=`echo $line | cut -d "," -f3`
phone=`echo $line | cut -d "," -f4`
type=`echo $line | cut -d "," -f5`
clear
echo -e "Enter the pay"
echo -en "Enter ID: "
read empid_search
#Check if particular entry to search for existed to perform deletion
if [ `count_lines "^${empid_search},"` -eq 0 ]
then
echo "Error: This particular record does not exist!!"
else
echo "Please verify update of this employee's record: " #Prompt for confirmation of employee details
echo
echo "Employee's Details: "
locate_lines "^${empid_search}," #Find location of the entry
if [$type="Salaried"]
then
echo "$name is a Salaried"
echo "Enter Salary :"
read salary
echo "${empID},${name},${job},${phone},${Type},${salary}" >> tmpfile ; mv tmpfile $data
echo " particulars has been updated!!"
fi
else
echo "f"
fi
}
文字文件
3,Frak,IT,9765753,Salaried
1,May,CEO,9789292,Salaried
5,Samy,Sales user,92221312,Commission
2,Orange,cleaner,935233233,Hourly
错误:
line 371: [=Salaried]: command not found
答案 0 :(得分:5)
这是问题:
if [$type="Salaried"]
在比较[
和]
中的值时,您需要有空格:
if [ "$type" = "Salaried" ]