Integer expression expected error in shell script

后端 未结 6 1478
自闭症患者
自闭症患者 2020-12-17 08:36

I\'m a newbie to shell scripts so I have a question. What Im doing wrong in this code?

#!/bin/bash
echo \" Write in your age: \"
read age
if [ \"$age\" -le \         


        
6条回答
  •  执念已碎
    2020-12-17 09:08

    If you are just comparing numbers, I think there's no need to change syntax, just correct those lines, lines 6 and 9 brackets.

    Line 6 before: if [ "$age" -le "7"] -o [ "$age" -ge " 65" ]

    After: if [ "$age" -le "7" -o "$age" -ge "65" ]

    Line 9 before: elif [ "$age" -gt "7"] -a [ "$age" -lt "65"]

    After: elif [ "$age" -gt "7" -a "$age" -lt "65" ]

提交回复
热议问题