if last command successful bash

By December 16, 2017Linux

This is the easiest way to check if the last command was succesful in bash.
[raw] your_command_to_test
if [ $? -eq 0 ]; then
echo OK
else
echo FAIL
fi
[/raw]

Leave a Reply