if last command successful bash

By December 16, 2017Linux

This is the easiest way to check if the last command was succesful in bash.

your_command_to_test
if [ $? -eq 0 ]; then
echo OK
else
echo FAIL
fi

Leave a Reply