(Question SOLVED and edited for helping someone else that need it or have the same mistake, now with the code in the post for better readability)
I am trying to create a script that does something if my disk arrays fail. When I run the command it have to return the number 4 (grep counted 4 times the word OK, one time for each disk).
Then I want to check if there where 4 or less OKs and do something.
#!/bin/bash $okdevices = hpssacli controller slot=4 physicaldrive all show | grep -c "OK" if [ $okdevices -lt 4 ] then echo "disk missing" fi
This returns that expect an unary operator.
Corrected thanks to comments and answer:
#!/bin/bash okdevices="$(hpssacli controller slot=4 physicaldrive all show | grep -c OK)" if [ $okdevices -lt 4 ]; then echo "missing disk" fi
Now works fine.
Thank you very much!