在Linux中创建一个唯一的列(更像是一个sql主键?)

时间:2015-06-17 19:24:39

标签: linux bash primary-key

所以我是Linux的新手,我们的导师给了我们这个任务,它非常简单,但我还没有能够为我的员工代码创建一个独特的专栏' (我们需要这个以避免重复代码) 我尝试了以下两种方法

方法1

    echo "Enter an Employee Code:
 read code
    if [$code uniq -u]
 then
    echo "Enter surname"
 read surname
    echo "Enter Other names"
 read other_names
    echo "Choose Gender"
    echo "f Female  m male"
 read gender
    case $gender in

         f) Female;;
         m) Male;;
         *) echo" that was not one of the choices"
           esac
    echo " Enter DOB"
 read dob
    echo "Enter Phone Number"
 read phone_num
    echo "$code   $surname   $other_names   $gender   $dob" >> details

否则      echo"重复员工代码"      网络

方法2

     echo "Enter an Employee Code:
 read code
     while [ $code -ne $code ]
 do
     echo "Enter surname"
 read surname
     echo "Enter Other names"
 read other_names
     echo "Choose Gender"
     echo "f Female  m male"
 read gender
    case $gender in
          f) Female;;
          m) Male;;
          *) echo" that was not one of the choices"
            esac
   echo " Enter DOB"
 read dob
   echo "Enter Phone Number"
 read phone_num
   echo "$code   $surname   $other_names   $gender   $dob" >> details

否则        echo"重复员工代码"

完成

有人可以帮忙吗? 方法1 无法识别" uniq"约束,而方法2 保持不停增量。非常感谢提前:))

0 个答案:

没有答案