if, elif, else statement issues in Bash

后端 未结 5 2173
忘了有多久
忘了有多久 2020-11-28 01:25

I can\'t seem to work out what the issue with the following if statement is in regards to the elif and then. Keep in mind the pr

5条回答
  •  野性不改
    2020-11-28 01:51

    Missing space between elif and [ rest your program is correct. you need to correct it an check it out. here is fixed program:

    #!/bin/bash
    
    if [ "$seconds" -eq 0 ]; then
       timezone_string="Z"
    elif [ "$seconds" -gt 0 ]; then
       timezone_string=$(printf "%02d:%02d" $((seconds/3600)) $(((seconds / 60) % 60)))
    else
       echo "Unknown parameter"
    fi
    

    useful link related to this bash if else statement

提交回复
热议问题