Answer the question
In order to leave comments, you need to log in
Why is the bash condition not checked?
Please tell me why in each of the conditions, the second part of the condition, the check passes as true?
It is necessary that the condition be executed once before the state of the stat value changes, what is my mistake?
#!/bin/bash
val="true"
while [ "1" -ne "0" ]
do
#stat=`iwinfo wlan0 assoclist | grep -o B0:E2:35:C5:F5:0A`
stat="dsfsdf"
if ; then
echo $val
val=false
echo 1
echo $stat
echo $val
elif ([ -z "$stat" ] && ); then
val="true"
echo 2
echo $stat
echo $val
fi
sleep 5
done
exit
Answer the question
In order to leave comments, you need to log in
I figured it out using the article https://habrahabr.ru/post/47706/
#!/bin/bash
val=true
while true
do
#stat=`iwinfo wlan0 assoclist | grep -o B0:E2:35:C5:F5:0A`
stat="dsfsdf"
if [ -n "$stat" -a true = "$val" ]; then
echo $val
val=false
echo $stat
echo $val
elif [ -z "$stat" -a false = "$val" ]; then
val="true"
echo $stat
echo $val
fi
sleep 5
done
exit
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question