I have the following bash script
i=1
while SH= read -r LINE
do
if echo $LINE | grep 'Network connection down!'
then
echo "shutdown"
exit
elif echo $LINE | grep 'Network connection available'
then
echo $LINE
((i++))
fi
done < <(tac /var/log/messages)
This script works so far. I am not an expert at shell scripting. I am trying to add an and operator to the first conditional statement, something like this
if echo $LINE | grep 'Network connection down!' && $i<4
Can anyone help show me how to make this work in shell script, every variation I have tried so far ends with various errors like
conditional binary operator expected
and various other ones that I can describe. Many thanks to everyone in advance :)
[[ $i < 4 ]]if echo $LINE | grep 'Network connection down!' && [[$i<4]]?[[ ... ]]<, it's important[[ i < 4 ]]won't do what you intend ifi=39.