lundi 17 février 2020

Why bash script using if and grep works one every other call?

root@xxx:/#  [ "`date | grep 20 | echo $?`" -gt "0" ] && echo 12
root@xxx:/#  [ "`date | grep 20 | echo $?`" -gt "0" ] && echo 12
12
root@xxx:/#  [ "`date | grep 20 | echo $?`" -gt "0" ] && echo 12
root@xxx:/#  [ "`date | grep 20 | echo $?`" -gt "0" ] && echo 12
12
root@xxx:/#  [ "`date | grep 20 | echo $?`" -gt "0" ] && echo 12
root@xxx:/#  [ "`date | grep 20 | echo $?`" -gt "0" ] && echo 12
12

It should echo 12 on every line, but do so only on odd lines. Why? How to fix?

Aucun commentaire:

Enregistrer un commentaire