This script wont sort correctly by age

前端 未结 2 1053
花落未央
花落未央 2021-01-16 06:28

My script asks for a name, phone number, and date of birth and then amends these details to a comma separated value file called “birthday.csv”.

It then Sorts “birt

相关标签:
2条回答
  • 2021-01-16 06:56

    Firstly remove the brackets around "$(currentDay)" and "$(currentDay)"

    0 讨论(0)
  • 2021-01-16 07:02

    One bug you have, at least:

    if [[ "$currentMonth" -lt "$birthMonth" ]] || [[ "$currentMonth" -eq "$birthMonth" && "$(currentDay)" -lt "$($birthDay)" ]]
    

    "$(currentDay)" should be just "$currentDay" and "$($birthDay)" should be just "$birthDay".

    You also have a typo here:

    currentMonth=${currenDate:0:2}
    

    That should be currentDate. Put set -u at the top of your script to catch such mistakes.

    Also, like Mat said, I don't see any sorting code :)

    0 讨论(0)
提交回复
热议问题