1

我收到一个错误,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
4

1 回答 1

5

这是问题行:

if [$type="Salaried"]

[比较和中的值时需要有空格]

if [ "$type" = "Salaried" ]
于 2013-11-04T15:32:18.587 回答