How to compare a variable with a value like 00:00:10 ?
Thanks
How to compare a variable with a value like 00:00:10 ?
Thanks
[ $yourvariable = "00:00:10" ]
its giving the syntax error
syntax error in expression (error token is ":00:00")
#! /bin/bash
IN_A='01:02:03'
IN_B='04:05:06'
VAL_A=$( echo $IN_A | sed 's/://g' )
VAL_B=$( echo $IN_B | sed 's/://g' )
if [ $VAL_A -gt $VAL_B ]
then
echo "$VAL_A <gt> $VAL_B"
else
echo "$VAL_B <gt> $VAL_A"
fi
exit 0
#!/bin/bash
var="00:00:10"
varbis="00:00:09"
if [ $var = "00:00:10" ] ;then
echo same
fi
if [ $varbis != "00:00:10" ] ;then
echo not the same
fi
exit
be careful to let spaces between each fields between the [ ].
[ $var = "00:00:10" ]
isn't the same as
[$var = "00:00:10"]
Regards