hi team,
i want to compare the below string from logs, but its is not working.
if [[ $res != "percent: 0%" ]]; then
echo "restart some process"
fi
hi team,
i want to compare the below string from logs, but its is not working.
if [[ $res != "percent: 0%" ]]; then
echo "restart some process"
fi
Please use code tags as required by forum rules!
WHAT is not working? Any errror messages? What's the contents of res
?
In addition to what RudiC said, variables which contain spaces or special chars should be within quotes.
i tail the log and grep
FE_get_pool_threshold_congestion | percent: 0%
if % is increased by 1 e.g 1% i want to restart process the process
tells us absolutely nothing about what is contained in the variable res
in your script. We can easily state that if you effectively have done the assignment:
res="FE_get_pool_threshold_congestion | percent: 0%"
then the test:
if [ "$res" != "percent: 0%" ]
then echo "restart some process"
fi
will ALWAYS print restart some process
if you're using a shell that is based on Bourne shell syntax.
The code you supplied could behave the same as the code shown above, give a syntax error, or do various other things depending on how res
was set, what shell you're using, and what operating system you're using.