How can one extract the exit code of a command and use it in a condition? For example look at the following script:
i=4
if [[ $i -eq 4 && $(command) -eq 0 ]]
then
echo "OK"
else
echo "KO"
fi
If both the conditions are satisfied the script should do something. In the second condition, I need the check on the exit status (and not the command output as is the case in the script given above), to know if the command was successful or not.