i want to write fucntion, that check previous command. Succes or not.
My code:
#!/bin/bash
function check_previous {
RESULT=$?
if [ $RESULT -eq 0 ]; then
echo "success"
else
echo "failed"
fi
}
echo "wwe"
check_previous
ls - l
check_previous
Yes, it works. No problem. But, i have a lot of command, that i should check, one by one. And i have only two messages "success" and "failed". But if i want to add a several messages "directory successfully deleted" or "file was changed". how to do this in one function for different command ? for creating file "file was created", for "deleting", "file was deleted". Any idea ?